Merge pull request #110 from TheBlueMatt/main
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 extern void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
16         return val == 0xdeadbeef0badf00dULL;
17 }
18
19
20 void *malloc(size_t size);
21 void free(void *ptr);
22
23 #define MALLOC(a, _) malloc(a)
24 #define do_MALLOC(a, _b, _c) malloc(a)
25 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
26 #define DO_ASSERT(a) (void)(a)
27 #define CHECK(a)
28 #define CHECK_ACCESS(p)
29 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
30
31 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
32 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
33 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
35
36 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
37
38 #define DECL_ARR_TYPE(ty, name) \
39         struct name##array { \
40                 uint32_t arr_len; \
41                 ty elems[]; \
42         }; \
43         typedef struct name##array * name##Array; \
44         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
45                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
46                 arr->arr_len = arr_len; \
47                 return arr; \
48         }
49
50 DECL_ARR_TYPE(int64_t, int64_t);
51 DECL_ARR_TYPE(int8_t, int8_t);
52 DECL_ARR_TYPE(uint32_t, uint32_t);
53 DECL_ARR_TYPE(void*, ptr);
54 DECL_ARR_TYPE(char, char);
55 typedef charArray jstring;
56
57 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
58         charArray arr = init_charArray(len, __LINE__);
59         memcpy(arr->elems, chars, len);
60         return arr;
61 }
62 static inline LDKStr str_ref_to_owned_c(const jstring str) {
63         char* newchars = MALLOC(str->arr_len + 1, "String chars");
64         memcpy(newchars, str->elems, str->arr_len);
65         newchars[str->arr_len] = 0;
66         LDKStr res = {
67                 .chars = newchars,
68                 .len = str->arr_len,
69                 .chars_is_owned = true
70         };
71         return res;
72 }
73
74 typedef bool jboolean;
75
76 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
77         return (uint32_t)MALLOC(size, "JS-Called malloc");
78 }
79 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
80         FREE((void*)ptr);
81 }
82
83 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
84         const char *res = check_get_ldk_bindings_version();
85         if (res == NULL) return NULL;
86         return str_ref_to_ts(res, strlen(res));
87 }
88 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
89         const char *res = check_get_ldk_version();
90         if (res == NULL) return NULL;
91         return str_ref_to_ts(res, strlen(res));
92 }
93 #include "version.c"
94 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
95 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
96         switch (ord) {
97                 case 0: return LDKAccessError_UnknownChain;
98                 case 1: return LDKAccessError_UnknownTx;
99         }
100         abort();
101 }
102 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
103         switch (val) {
104                 case LDKAccessError_UnknownChain: return 0;
105                 case LDKAccessError_UnknownTx: return 1;
106                 default: abort();
107         }
108 }
109 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
110         switch (ord) {
111                 case 0: return LDKCOption_NoneZ_Some;
112                 case 1: return LDKCOption_NoneZ_None;
113         }
114         abort();
115 }
116 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
117         switch (val) {
118                 case LDKCOption_NoneZ_Some: return 0;
119                 case LDKCOption_NoneZ_None: return 1;
120                 default: abort();
121         }
122 }
123 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
124         switch (ord) {
125                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
126                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
127         }
128         abort();
129 }
130 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
131         switch (val) {
132                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
133                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
134                 default: abort();
135         }
136 }
137 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
138         switch (ord) {
139                 case 0: return LDKConfirmationTarget_Background;
140                 case 1: return LDKConfirmationTarget_Normal;
141                 case 2: return LDKConfirmationTarget_HighPriority;
142         }
143         abort();
144 }
145 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
146         switch (val) {
147                 case LDKConfirmationTarget_Background: return 0;
148                 case LDKConfirmationTarget_Normal: return 1;
149                 case LDKConfirmationTarget_HighPriority: return 2;
150                 default: abort();
151         }
152 }
153 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKCreationError_DescriptionTooLong;
156                 case 1: return LDKCreationError_RouteTooLong;
157                 case 2: return LDKCreationError_TimestampOutOfBounds;
158                 case 3: return LDKCreationError_InvalidAmount;
159                 case 4: return LDKCreationError_MissingRouteHints;
160         }
161         abort();
162 }
163 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
164         switch (val) {
165                 case LDKCreationError_DescriptionTooLong: return 0;
166                 case LDKCreationError_RouteTooLong: return 1;
167                 case LDKCreationError_TimestampOutOfBounds: return 2;
168                 case LDKCreationError_InvalidAmount: return 3;
169                 case LDKCreationError_MissingRouteHints: return 4;
170                 default: abort();
171         }
172 }
173 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
174         switch (ord) {
175                 case 0: return LDKCurrency_Bitcoin;
176                 case 1: return LDKCurrency_BitcoinTestnet;
177                 case 2: return LDKCurrency_Regtest;
178                 case 3: return LDKCurrency_Simnet;
179                 case 4: return LDKCurrency_Signet;
180         }
181         abort();
182 }
183 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
184         switch (val) {
185                 case LDKCurrency_Bitcoin: return 0;
186                 case LDKCurrency_BitcoinTestnet: return 1;
187                 case LDKCurrency_Regtest: return 2;
188                 case LDKCurrency_Simnet: return 3;
189                 case LDKCurrency_Signet: return 4;
190                 default: abort();
191         }
192 }
193 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKIOError_NotFound;
196                 case 1: return LDKIOError_PermissionDenied;
197                 case 2: return LDKIOError_ConnectionRefused;
198                 case 3: return LDKIOError_ConnectionReset;
199                 case 4: return LDKIOError_ConnectionAborted;
200                 case 5: return LDKIOError_NotConnected;
201                 case 6: return LDKIOError_AddrInUse;
202                 case 7: return LDKIOError_AddrNotAvailable;
203                 case 8: return LDKIOError_BrokenPipe;
204                 case 9: return LDKIOError_AlreadyExists;
205                 case 10: return LDKIOError_WouldBlock;
206                 case 11: return LDKIOError_InvalidInput;
207                 case 12: return LDKIOError_InvalidData;
208                 case 13: return LDKIOError_TimedOut;
209                 case 14: return LDKIOError_WriteZero;
210                 case 15: return LDKIOError_Interrupted;
211                 case 16: return LDKIOError_Other;
212                 case 17: return LDKIOError_UnexpectedEof;
213         }
214         abort();
215 }
216 static inline int32_t LDKIOError_to_js(LDKIOError val) {
217         switch (val) {
218                 case LDKIOError_NotFound: return 0;
219                 case LDKIOError_PermissionDenied: return 1;
220                 case LDKIOError_ConnectionRefused: return 2;
221                 case LDKIOError_ConnectionReset: return 3;
222                 case LDKIOError_ConnectionAborted: return 4;
223                 case LDKIOError_NotConnected: return 5;
224                 case LDKIOError_AddrInUse: return 6;
225                 case LDKIOError_AddrNotAvailable: return 7;
226                 case LDKIOError_BrokenPipe: return 8;
227                 case LDKIOError_AlreadyExists: return 9;
228                 case LDKIOError_WouldBlock: return 10;
229                 case LDKIOError_InvalidInput: return 11;
230                 case LDKIOError_InvalidData: return 12;
231                 case LDKIOError_TimedOut: return 13;
232                 case LDKIOError_WriteZero: return 14;
233                 case LDKIOError_Interrupted: return 15;
234                 case LDKIOError_Other: return 16;
235                 case LDKIOError_UnexpectedEof: return 17;
236                 default: abort();
237         }
238 }
239 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
240         switch (ord) {
241                 case 0: return LDKLevel_Gossip;
242                 case 1: return LDKLevel_Trace;
243                 case 2: return LDKLevel_Debug;
244                 case 3: return LDKLevel_Info;
245                 case 4: return LDKLevel_Warn;
246                 case 5: return LDKLevel_Error;
247         }
248         abort();
249 }
250 static inline int32_t LDKLevel_to_js(LDKLevel val) {
251         switch (val) {
252                 case LDKLevel_Gossip: return 0;
253                 case LDKLevel_Trace: return 1;
254                 case LDKLevel_Debug: return 2;
255                 case LDKLevel_Info: return 3;
256                 case LDKLevel_Warn: return 4;
257                 case LDKLevel_Error: return 5;
258                 default: abort();
259         }
260 }
261 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
262         switch (ord) {
263                 case 0: return LDKNetwork_Bitcoin;
264                 case 1: return LDKNetwork_Testnet;
265                 case 2: return LDKNetwork_Regtest;
266                 case 3: return LDKNetwork_Signet;
267         }
268         abort();
269 }
270 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
271         switch (val) {
272                 case LDKNetwork_Bitcoin: return 0;
273                 case LDKNetwork_Testnet: return 1;
274                 case LDKNetwork_Regtest: return 2;
275                 case LDKNetwork_Signet: return 3;
276                 default: abort();
277         }
278 }
279 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
280         switch (ord) {
281                 case 0: return LDKRecipient_Node;
282                 case 1: return LDKRecipient_PhantomNode;
283         }
284         abort();
285 }
286 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
287         switch (val) {
288                 case LDKRecipient_Node: return 0;
289                 case LDKRecipient_PhantomNode: return 1;
290                 default: abort();
291         }
292 }
293 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
294         switch (ord) {
295                 case 0: return LDKSecp256k1Error_IncorrectSignature;
296                 case 1: return LDKSecp256k1Error_InvalidMessage;
297                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
298                 case 3: return LDKSecp256k1Error_InvalidSignature;
299                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
300                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
301                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
302                 case 7: return LDKSecp256k1Error_InvalidTweak;
303                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
304                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
305                 case 10: return LDKSecp256k1Error_InvalidParityValue;
306         }
307         abort();
308 }
309 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
310         switch (val) {
311                 case LDKSecp256k1Error_IncorrectSignature: return 0;
312                 case LDKSecp256k1Error_InvalidMessage: return 1;
313                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
314                 case LDKSecp256k1Error_InvalidSignature: return 3;
315                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
316                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
317                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
318                 case LDKSecp256k1Error_InvalidTweak: return 7;
319                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
320                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
321                 case LDKSecp256k1Error_InvalidParityValue: return 10;
322                 default: abort();
323         }
324 }
325 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
326         switch (ord) {
327                 case 0: return LDKSemanticError_NoPaymentHash;
328                 case 1: return LDKSemanticError_MultiplePaymentHashes;
329                 case 2: return LDKSemanticError_NoDescription;
330                 case 3: return LDKSemanticError_MultipleDescriptions;
331                 case 4: return LDKSemanticError_NoPaymentSecret;
332                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
333                 case 6: return LDKSemanticError_InvalidFeatures;
334                 case 7: return LDKSemanticError_InvalidRecoveryId;
335                 case 8: return LDKSemanticError_InvalidSignature;
336                 case 9: return LDKSemanticError_ImpreciseAmount;
337         }
338         abort();
339 }
340 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
341         switch (val) {
342                 case LDKSemanticError_NoPaymentHash: return 0;
343                 case LDKSemanticError_MultiplePaymentHashes: return 1;
344                 case LDKSemanticError_NoDescription: return 2;
345                 case LDKSemanticError_MultipleDescriptions: return 3;
346                 case LDKSemanticError_NoPaymentSecret: return 4;
347                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
348                 case LDKSemanticError_InvalidFeatures: return 6;
349                 case LDKSemanticError_InvalidRecoveryId: return 7;
350                 case LDKSemanticError_InvalidSignature: return 8;
351                 case LDKSemanticError_ImpreciseAmount: return 9;
352                 default: abort();
353         }
354 }
355 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
356         switch (ord) {
357                 case 0: return LDKSiPrefix_Milli;
358                 case 1: return LDKSiPrefix_Micro;
359                 case 2: return LDKSiPrefix_Nano;
360                 case 3: return LDKSiPrefix_Pico;
361         }
362         abort();
363 }
364 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
365         switch (val) {
366                 case LDKSiPrefix_Milli: return 0;
367                 case LDKSiPrefix_Micro: return 1;
368                 case LDKSiPrefix_Nano: return 2;
369                 case LDKSiPrefix_Pico: return 3;
370                 default: abort();
371         }
372 }
373 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
374         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
375         switch(obj->tag) {
376                 case LDKBech32Error_MissingSeparator: return 0;
377                 case LDKBech32Error_InvalidChecksum: return 1;
378                 case LDKBech32Error_InvalidLength: return 2;
379                 case LDKBech32Error_InvalidChar: return 3;
380                 case LDKBech32Error_InvalidData: return 4;
381                 case LDKBech32Error_InvalidPadding: return 5;
382                 case LDKBech32Error_MixedCase: return 6;
383                 default: abort();
384         }
385 }
386 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
387         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
388         assert(obj->tag == LDKBech32Error_InvalidChar);
389                         int32_t invalid_char_conv = obj->invalid_char;
390         return invalid_char_conv;
391 }
392 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
393         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
394         assert(obj->tag == LDKBech32Error_InvalidData);
395                         int8_t invalid_data_conv = obj->invalid_data;
396         return invalid_data_conv;
397 }
398 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
399         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
400         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
401         return ret;
402 }
403 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) {
404         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
405         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
406         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
407         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
408         CVec_u8Z_free(ret_var);
409         return ret_arr;
410 }
411
412 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) {
413         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
414         int64_t ret_conv = TxOut_get_value(thing_conv);
415         return ret_conv;
416 }
417
418 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
419 CHECK(owner->result_ok);
420         return *owner->contents.result;
421 }
422 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
423         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
424         CResult_NoneNoneZ_get_ok(owner_conv);
425 }
426
427 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
428 CHECK(!owner->result_ok);
429         return *owner->contents.err;
430 }
431 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
432         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
433         CResult_NoneNoneZ_get_err(owner_conv);
434 }
435
436 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
437 CHECK(owner->result_ok);
438         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
439 }
440 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
441         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
442         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
443         uint32_t ret_ref = 0;
444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
447         ret_ref = (uintptr_t)ret_var.inner;
448         if (ret_var.is_owned) {
449                 ret_ref |= 1;
450         }
451         return ret_ref;
452 }
453
454 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
455 CHECK(!owner->result_ok);
456         return DecodeError_clone(&*owner->contents.err);
457 }
458 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
459         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
460         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
461         uint32_t ret_ref = 0;
462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
465         ret_ref = (uintptr_t)ret_var.inner;
466         if (ret_var.is_owned) {
467                 ret_ref |= 1;
468         }
469         return ret_ref;
470 }
471
472 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
473 CHECK(owner->result_ok);
474         return *owner->contents.result;
475 }
476 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
477         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
478         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
479         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
480         return ret_arr;
481 }
482
483 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
484 CHECK(!owner->result_ok);
485         return *owner->contents.err;
486 }
487 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
488         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
489         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
490         return ret_conv;
491 }
492
493 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
494 CHECK(owner->result_ok);
495         return *owner->contents.result;
496 }
497 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
498         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
499         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
500         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
501         return ret_arr;
502 }
503
504 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
505 CHECK(!owner->result_ok);
506         return *owner->contents.err;
507 }
508 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
509         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
510         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
511         return ret_conv;
512 }
513
514 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
515 CHECK(owner->result_ok);
516         return TxCreationKeys_clone(&*owner->contents.result);
517 }
518 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
519         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
520         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
521         uint32_t ret_ref = 0;
522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
525         ret_ref = (uintptr_t)ret_var.inner;
526         if (ret_var.is_owned) {
527                 ret_ref |= 1;
528         }
529         return ret_ref;
530 }
531
532 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
533 CHECK(!owner->result_ok);
534         return DecodeError_clone(&*owner->contents.err);
535 }
536 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
537         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
538         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
539         uint32_t ret_ref = 0;
540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
543         ret_ref = (uintptr_t)ret_var.inner;
544         if (ret_var.is_owned) {
545                 ret_ref |= 1;
546         }
547         return ret_ref;
548 }
549
550 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
551 CHECK(owner->result_ok);
552         return ChannelPublicKeys_clone(&*owner->contents.result);
553 }
554 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
555         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
556         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
557         uint32_t ret_ref = 0;
558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
561         ret_ref = (uintptr_t)ret_var.inner;
562         if (ret_var.is_owned) {
563                 ret_ref |= 1;
564         }
565         return ret_ref;
566 }
567
568 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
569 CHECK(!owner->result_ok);
570         return DecodeError_clone(&*owner->contents.err);
571 }
572 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
573         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
574         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
575         uint32_t ret_ref = 0;
576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
579         ret_ref = (uintptr_t)ret_var.inner;
580         if (ret_var.is_owned) {
581                 ret_ref |= 1;
582         }
583         return ret_ref;
584 }
585
586 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
587 CHECK(owner->result_ok);
588         return TxCreationKeys_clone(&*owner->contents.result);
589 }
590 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
591         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
592         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
593         uint32_t ret_ref = 0;
594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
597         ret_ref = (uintptr_t)ret_var.inner;
598         if (ret_var.is_owned) {
599                 ret_ref |= 1;
600         }
601         return ret_ref;
602 }
603
604 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
605 CHECK(!owner->result_ok);
606         return *owner->contents.err;
607 }
608 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
609         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
610         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
611         return ret_conv;
612 }
613
614 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
615         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
616         switch(obj->tag) {
617                 case LDKCOption_u32Z_Some: return 0;
618                 case LDKCOption_u32Z_None: return 1;
619                 default: abort();
620         }
621 }
622 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
623         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
624         assert(obj->tag == LDKCOption_u32Z_Some);
625                         int32_t some_conv = obj->some;
626         return some_conv;
627 }
628 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
629 CHECK(owner->result_ok);
630         return HTLCOutputInCommitment_clone(&*owner->contents.result);
631 }
632 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
633         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
634         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
635         uint32_t ret_ref = 0;
636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
639         ret_ref = (uintptr_t)ret_var.inner;
640         if (ret_var.is_owned) {
641                 ret_ref |= 1;
642         }
643         return ret_ref;
644 }
645
646 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
647 CHECK(!owner->result_ok);
648         return DecodeError_clone(&*owner->contents.err);
649 }
650 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
651         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
652         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
653         uint32_t ret_ref = 0;
654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
657         ret_ref = (uintptr_t)ret_var.inner;
658         if (ret_var.is_owned) {
659                 ret_ref |= 1;
660         }
661         return ret_ref;
662 }
663
664 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
665 CHECK(owner->result_ok);
666         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
667 }
668 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
669         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
670         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
671         uint32_t ret_ref = 0;
672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
675         ret_ref = (uintptr_t)ret_var.inner;
676         if (ret_var.is_owned) {
677                 ret_ref |= 1;
678         }
679         return ret_ref;
680 }
681
682 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
683 CHECK(!owner->result_ok);
684         return DecodeError_clone(&*owner->contents.err);
685 }
686 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
687         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
688         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
689         uint32_t ret_ref = 0;
690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
693         ret_ref = (uintptr_t)ret_var.inner;
694         if (ret_var.is_owned) {
695                 ret_ref |= 1;
696         }
697         return ret_ref;
698 }
699
700 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
701 CHECK(owner->result_ok);
702         return ChannelTransactionParameters_clone(&*owner->contents.result);
703 }
704 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
705         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
706         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
707         uint32_t ret_ref = 0;
708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
711         ret_ref = (uintptr_t)ret_var.inner;
712         if (ret_var.is_owned) {
713                 ret_ref |= 1;
714         }
715         return ret_ref;
716 }
717
718 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
719 CHECK(!owner->result_ok);
720         return DecodeError_clone(&*owner->contents.err);
721 }
722 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
723         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
724         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
725         uint32_t ret_ref = 0;
726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
729         ret_ref = (uintptr_t)ret_var.inner;
730         if (ret_var.is_owned) {
731                 ret_ref |= 1;
732         }
733         return ret_ref;
734 }
735
736 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
737 CHECK(owner->result_ok);
738         return HolderCommitmentTransaction_clone(&*owner->contents.result);
739 }
740 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
741         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
742         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
743         uint32_t ret_ref = 0;
744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
747         ret_ref = (uintptr_t)ret_var.inner;
748         if (ret_var.is_owned) {
749                 ret_ref |= 1;
750         }
751         return ret_ref;
752 }
753
754 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
755 CHECK(!owner->result_ok);
756         return DecodeError_clone(&*owner->contents.err);
757 }
758 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
759         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
760         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
761         uint32_t ret_ref = 0;
762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
765         ret_ref = (uintptr_t)ret_var.inner;
766         if (ret_var.is_owned) {
767                 ret_ref |= 1;
768         }
769         return ret_ref;
770 }
771
772 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
773 CHECK(owner->result_ok);
774         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
775 }
776 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
777         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
778         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
779         uint32_t ret_ref = 0;
780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
783         ret_ref = (uintptr_t)ret_var.inner;
784         if (ret_var.is_owned) {
785                 ret_ref |= 1;
786         }
787         return ret_ref;
788 }
789
790 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
791 CHECK(!owner->result_ok);
792         return DecodeError_clone(&*owner->contents.err);
793 }
794 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
795         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
796         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
797         uint32_t ret_ref = 0;
798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
801         ret_ref = (uintptr_t)ret_var.inner;
802         if (ret_var.is_owned) {
803                 ret_ref |= 1;
804         }
805         return ret_ref;
806 }
807
808 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
809 CHECK(owner->result_ok);
810         return &*owner->contents.result;
811 }
812 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
813         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
814         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
815         uint32_t ret_ref = 0;
816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
819         ret_ref = (uintptr_t)ret_var.inner & ~1;
820         return ret_ref;
821 }
822
823 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
824 CHECK(!owner->result_ok);
825         return *owner->contents.err;
826 }
827 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
828         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
829         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
830 }
831
832 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
833 CHECK(owner->result_ok);
834         return CommitmentTransaction_clone(&*owner->contents.result);
835 }
836 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
837         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
838         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
839         uint32_t ret_ref = 0;
840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
843         ret_ref = (uintptr_t)ret_var.inner;
844         if (ret_var.is_owned) {
845                 ret_ref |= 1;
846         }
847         return ret_ref;
848 }
849
850 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
851 CHECK(!owner->result_ok);
852         return DecodeError_clone(&*owner->contents.err);
853 }
854 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
855         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
856         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
857         uint32_t ret_ref = 0;
858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
861         ret_ref = (uintptr_t)ret_var.inner;
862         if (ret_var.is_owned) {
863                 ret_ref |= 1;
864         }
865         return ret_ref;
866 }
867
868 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
869 CHECK(owner->result_ok);
870         return &*owner->contents.result;
871 }
872 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
873         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
874         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
875         uint32_t ret_ref = 0;
876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
879         ret_ref = (uintptr_t)ret_var.inner & ~1;
880         return ret_ref;
881 }
882
883 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
884 CHECK(!owner->result_ok);
885         return *owner->contents.err;
886 }
887 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
888         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
889         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
890 }
891
892 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
893 CHECK(owner->result_ok);
894         return *owner->contents.result;
895 }
896 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
897         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
898         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
899         ptrArray ret_arr = NULL;
900         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
901         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
902         for (size_t m = 0; m < ret_var.datalen; m++) {
903                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
904                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
905                 ret_arr_ptr[m] = ret_conv_12_arr;
906         }
907         
908         return ret_arr;
909 }
910
911 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
912 CHECK(!owner->result_ok);
913         return *owner->contents.err;
914 }
915 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
916         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
917         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
918 }
919
920 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
921 CHECK(owner->result_ok);
922         return ShutdownScript_clone(&*owner->contents.result);
923 }
924 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
925         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
926         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
927         uint32_t ret_ref = 0;
928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
931         ret_ref = (uintptr_t)ret_var.inner;
932         if (ret_var.is_owned) {
933                 ret_ref |= 1;
934         }
935         return ret_ref;
936 }
937
938 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
939 CHECK(!owner->result_ok);
940         return DecodeError_clone(&*owner->contents.err);
941 }
942 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
943         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
944         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
945         uint32_t ret_ref = 0;
946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
949         ret_ref = (uintptr_t)ret_var.inner;
950         if (ret_var.is_owned) {
951                 ret_ref |= 1;
952         }
953         return ret_ref;
954 }
955
956 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
957 CHECK(owner->result_ok);
958         return ShutdownScript_clone(&*owner->contents.result);
959 }
960 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
961         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
962         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
963         uint32_t ret_ref = 0;
964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
967         ret_ref = (uintptr_t)ret_var.inner;
968         if (ret_var.is_owned) {
969                 ret_ref |= 1;
970         }
971         return ret_ref;
972 }
973
974 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
975 CHECK(!owner->result_ok);
976         return InvalidShutdownScript_clone(&*owner->contents.err);
977 }
978 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
979         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
980         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
981         uint32_t ret_ref = 0;
982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
985         ret_ref = (uintptr_t)ret_var.inner;
986         if (ret_var.is_owned) {
987                 ret_ref |= 1;
988         }
989         return ret_ref;
990 }
991
992 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return RouteHop_clone(&*owner->contents.result);
995 }
996 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
997         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
998         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
999         uint32_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
1015         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1017         uint32_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1029         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1030         for (size_t i = 0; i < ret.datalen; i++) {
1031                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1032         }
1033         return ret;
1034 }
1035 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1036         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1037         for (size_t i = 0; i < ret.datalen; i++) {
1038                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1039         }
1040         return ret;
1041 }
1042 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return Route_clone(&*owner->contents.result);
1045 }
1046 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
1047         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1048         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1049         uint32_t ret_ref = 0;
1050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1053         ret_ref = (uintptr_t)ret_var.inner;
1054         if (ret_var.is_owned) {
1055                 ret_ref |= 1;
1056         }
1057         return ret_ref;
1058 }
1059
1060 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1061 CHECK(!owner->result_ok);
1062         return DecodeError_clone(&*owner->contents.err);
1063 }
1064 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1065         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1066         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(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 LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1079 CHECK(owner->result_ok);
1080         return RouteParameters_clone(&*owner->contents.result);
1081 }
1082 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1083         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1084         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1097 CHECK(!owner->result_ok);
1098         return DecodeError_clone(&*owner->contents.err);
1099 }
1100 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1101         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1102         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1103         uint32_t ret_ref = 0;
1104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1107         ret_ref = (uintptr_t)ret_var.inner;
1108         if (ret_var.is_owned) {
1109                 ret_ref |= 1;
1110         }
1111         return ret_ref;
1112 }
1113
1114 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1115         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1116         for (size_t i = 0; i < ret.datalen; i++) {
1117                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1118         }
1119         return ret;
1120 }
1121 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1122         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1123         switch(obj->tag) {
1124                 case LDKCOption_u64Z_Some: return 0;
1125                 case LDKCOption_u64Z_None: return 1;
1126                 default: abort();
1127         }
1128 }
1129 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1130         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1131         assert(obj->tag == LDKCOption_u64Z_Some);
1132                         int64_t some_conv = obj->some;
1133         return some_conv;
1134 }
1135 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1136         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1137         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1138         return ret;
1139 }
1140 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1141 CHECK(owner->result_ok);
1142         return PaymentParameters_clone(&*owner->contents.result);
1143 }
1144 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1145         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1146         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1147         uint32_t ret_ref = 0;
1148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1151         ret_ref = (uintptr_t)ret_var.inner;
1152         if (ret_var.is_owned) {
1153                 ret_ref |= 1;
1154         }
1155         return ret_ref;
1156 }
1157
1158 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1159 CHECK(!owner->result_ok);
1160         return DecodeError_clone(&*owner->contents.err);
1161 }
1162 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1163         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1164         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1165         uint32_t ret_ref = 0;
1166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1169         ret_ref = (uintptr_t)ret_var.inner;
1170         if (ret_var.is_owned) {
1171                 ret_ref |= 1;
1172         }
1173         return ret_ref;
1174 }
1175
1176 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1177         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1178         for (size_t i = 0; i < ret.datalen; i++) {
1179                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1180         }
1181         return ret;
1182 }
1183 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1184 CHECK(owner->result_ok);
1185         return RouteHint_clone(&*owner->contents.result);
1186 }
1187 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1188         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1189         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1190         uint32_t ret_ref = 0;
1191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1194         ret_ref = (uintptr_t)ret_var.inner;
1195         if (ret_var.is_owned) {
1196                 ret_ref |= 1;
1197         }
1198         return ret_ref;
1199 }
1200
1201 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1202 CHECK(!owner->result_ok);
1203         return DecodeError_clone(&*owner->contents.err);
1204 }
1205 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1206         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1207         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1208         uint32_t ret_ref = 0;
1209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1212         ret_ref = (uintptr_t)ret_var.inner;
1213         if (ret_var.is_owned) {
1214                 ret_ref |= 1;
1215         }
1216         return ret_ref;
1217 }
1218
1219 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1220 CHECK(owner->result_ok);
1221         return RouteHintHop_clone(&*owner->contents.result);
1222 }
1223 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1224         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1225         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1226         uint32_t ret_ref = 0;
1227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1230         ret_ref = (uintptr_t)ret_var.inner;
1231         if (ret_var.is_owned) {
1232                 ret_ref |= 1;
1233         }
1234         return ret_ref;
1235 }
1236
1237 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1238 CHECK(!owner->result_ok);
1239         return DecodeError_clone(&*owner->contents.err);
1240 }
1241 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1242         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1243         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1244         uint32_t ret_ref = 0;
1245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1248         ret_ref = (uintptr_t)ret_var.inner;
1249         if (ret_var.is_owned) {
1250                 ret_ref |= 1;
1251         }
1252         return ret_ref;
1253 }
1254
1255 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1256         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1257         for (size_t i = 0; i < ret.datalen; i++) {
1258                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1259         }
1260         return ret;
1261 }
1262 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1263 CHECK(owner->result_ok);
1264         return Route_clone(&*owner->contents.result);
1265 }
1266 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1267         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1268         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1269         uint32_t ret_ref = 0;
1270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1273         ret_ref = (uintptr_t)ret_var.inner;
1274         if (ret_var.is_owned) {
1275                 ret_ref |= 1;
1276         }
1277         return ret_ref;
1278 }
1279
1280 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1281 CHECK(!owner->result_ok);
1282         return LightningError_clone(&*owner->contents.err);
1283 }
1284 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1285         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1286         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1287         uint32_t ret_ref = 0;
1288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1291         ret_ref = (uintptr_t)ret_var.inner;
1292         if (ret_var.is_owned) {
1293                 ret_ref |= 1;
1294         }
1295         return ret_ref;
1296 }
1297
1298 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1299         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1300         switch(obj->tag) {
1301                 case LDKPaymentPurpose_InvoicePayment: return 0;
1302                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1303                 default: abort();
1304         }
1305 }
1306 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1307         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1308         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1309                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1310                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1311         return payment_preimage_arr;
1312 }
1313 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1314         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1315         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1316                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1317                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1318         return payment_secret_arr;
1319 }
1320 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1321         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1322         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1323                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1324                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1325         return spontaneous_payment_arr;
1326 }
1327 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1328 CHECK(owner->result_ok);
1329         return PaymentPurpose_clone(&*owner->contents.result);
1330 }
1331 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1332         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1333         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1334         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1335         uint32_t ret_ref = (uintptr_t)ret_copy;
1336         return ret_ref;
1337 }
1338
1339 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1340 CHECK(!owner->result_ok);
1341         return DecodeError_clone(&*owner->contents.err);
1342 }
1343 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1344         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1345         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1346         uint32_t ret_ref = 0;
1347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1350         ret_ref = (uintptr_t)ret_var.inner;
1351         if (ret_var.is_owned) {
1352                 ret_ref |= 1;
1353         }
1354         return ret_ref;
1355 }
1356
1357 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1358         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1359         switch(obj->tag) {
1360                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1361                 case LDKClosureReason_HolderForceClosed: return 1;
1362                 case LDKClosureReason_CooperativeClosure: return 2;
1363                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1364                 case LDKClosureReason_FundingTimedOut: return 4;
1365                 case LDKClosureReason_ProcessingError: return 5;
1366                 case LDKClosureReason_DisconnectedPeer: return 6;
1367                 case LDKClosureReason_OutdatedChannelManager: return 7;
1368                 default: abort();
1369         }
1370 }
1371 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1372         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1373         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1374                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1375                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1376         return peer_msg_conv;
1377 }
1378 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1379         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1380         assert(obj->tag == LDKClosureReason_ProcessingError);
1381                         LDKStr err_str = obj->processing_error.err;
1382                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1383         return err_conv;
1384 }
1385 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1386         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1387         switch(obj->tag) {
1388                 case LDKCOption_ClosureReasonZ_Some: return 0;
1389                 case LDKCOption_ClosureReasonZ_None: return 1;
1390                 default: abort();
1391         }
1392 }
1393 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1394         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1395         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1396                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1397         return some_ref;
1398 }
1399 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1400 CHECK(owner->result_ok);
1401         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1402 }
1403 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1404         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1405         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1406         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1407         uint32_t ret_ref = (uintptr_t)ret_copy;
1408         return ret_ref;
1409 }
1410
1411 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1412 CHECK(!owner->result_ok);
1413         return DecodeError_clone(&*owner->contents.err);
1414 }
1415 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1416         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1417         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1418         uint32_t ret_ref = 0;
1419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1422         ret_ref = (uintptr_t)ret_var.inner;
1423         if (ret_var.is_owned) {
1424                 ret_ref |= 1;
1425         }
1426         return ret_ref;
1427 }
1428
1429 uint32_t __attribute__((export_name("TS_LDKHTLCDestination_ty_from_ptr"))) TS_LDKHTLCDestination_ty_from_ptr(uint32_t ptr) {
1430         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1431         switch(obj->tag) {
1432                 case LDKHTLCDestination_NextHopChannel: return 0;
1433                 case LDKHTLCDestination_UnknownNextHop: return 1;
1434                 case LDKHTLCDestination_FailedPayment: return 2;
1435                 default: abort();
1436         }
1437 }
1438 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_node_id"))) TS_LDKHTLCDestination_NextHopChannel_get_node_id(uint32_t ptr) {
1439         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1440         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1441                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1442                         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
1443         return node_id_arr;
1444 }
1445 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_channel_id"))) TS_LDKHTLCDestination_NextHopChannel_get_channel_id(uint32_t ptr) {
1446         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1447         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1448                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1449                         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
1450         return channel_id_arr;
1451 }
1452 int64_t __attribute__((export_name("TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid"))) TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(uint32_t ptr) {
1453         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1454         assert(obj->tag == LDKHTLCDestination_UnknownNextHop);
1455                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
1456         return requested_forward_scid_conv;
1457 }
1458 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_FailedPayment_get_payment_hash"))) TS_LDKHTLCDestination_FailedPayment_get_payment_hash(uint32_t ptr) {
1459         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1460         assert(obj->tag == LDKHTLCDestination_FailedPayment);
1461                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1462                         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
1463         return payment_hash_arr;
1464 }
1465 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_ty_from_ptr"))) TS_LDKCOption_HTLCDestinationZ_ty_from_ptr(uint32_t ptr) {
1466         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1467         switch(obj->tag) {
1468                 case LDKCOption_HTLCDestinationZ_Some: return 0;
1469                 case LDKCOption_HTLCDestinationZ_None: return 1;
1470                 default: abort();
1471         }
1472 }
1473 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_Some_get_some"))) TS_LDKCOption_HTLCDestinationZ_Some_get_some(uint32_t ptr) {
1474         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1475         assert(obj->tag == LDKCOption_HTLCDestinationZ_Some);
1476                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1477         return some_ref;
1478 }
1479 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1480 CHECK(owner->result_ok);
1481         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
1482 }
1483 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(uint32_t owner) {
1484         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1485         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
1486         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
1487         uint32_t ret_ref = (uintptr_t)ret_copy;
1488         return ret_ref;
1489 }
1490
1491 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1492 CHECK(!owner->result_ok);
1493         return DecodeError_clone(&*owner->contents.err);
1494 }
1495 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(uint32_t owner) {
1496         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1497         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
1498         uint32_t ret_ref = 0;
1499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1502         ret_ref = (uintptr_t)ret_var.inner;
1503         if (ret_var.is_owned) {
1504                 ret_ref |= 1;
1505         }
1506         return ret_ref;
1507 }
1508
1509 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1510         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1511         switch(obj->tag) {
1512                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1513                 case LDKNetworkUpdate_ChannelFailure: return 1;
1514                 case LDKNetworkUpdate_NodeFailure: return 2;
1515                 default: abort();
1516         }
1517 }
1518 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1519         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1520         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1521                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1522                         uint32_t msg_ref = 0;
1523                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1524                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1525                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1526                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1527         return msg_ref;
1528 }
1529 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1530         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1531         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1532                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1533         return short_channel_id_conv;
1534 }
1535 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1536         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1537         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1538                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1539         return is_permanent_conv;
1540 }
1541 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1542         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1543         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1544                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1545                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1546         return node_id_arr;
1547 }
1548 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1549         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1550         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1551                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1552         return is_permanent_conv;
1553 }
1554 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1555         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1556         switch(obj->tag) {
1557                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1558                 case LDKCOption_NetworkUpdateZ_None: return 1;
1559                 default: abort();
1560         }
1561 }
1562 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1563         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1564         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1565                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1566         return some_ref;
1567 }
1568 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1569         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1570         switch(obj->tag) {
1571                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1572                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1573                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1574                 default: abort();
1575         }
1576 }
1577 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1578         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1579         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1580                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1581                         uint32_t outpoint_ref = 0;
1582                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1583                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1584                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1585                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1586         return outpoint_ref;
1587 }
1588 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1589         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1590         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1591                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1592         return (uint32_t)output_ref;
1593 }
1594 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1595         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1596         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1597                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1598                         uint32_t delayed_payment_output_ref = 0;
1599                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1600                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1601                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1602                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1603         return delayed_payment_output_ref;
1604 }
1605 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1606         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1607         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1608                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1609                         uint32_t static_payment_output_ref = 0;
1610                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1611                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1612                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1613                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1614         return static_payment_output_ref;
1615 }
1616 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1617         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1618         for (size_t i = 0; i < ret.datalen; i++) {
1619                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1620         }
1621         return ret;
1622 }
1623 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1624         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1625         switch(obj->tag) {
1626                 case LDKEvent_FundingGenerationReady: return 0;
1627                 case LDKEvent_PaymentReceived: return 1;
1628                 case LDKEvent_PaymentClaimed: return 2;
1629                 case LDKEvent_PaymentSent: return 3;
1630                 case LDKEvent_PaymentFailed: return 4;
1631                 case LDKEvent_PaymentPathSuccessful: return 5;
1632                 case LDKEvent_PaymentPathFailed: return 6;
1633                 case LDKEvent_ProbeSuccessful: return 7;
1634                 case LDKEvent_ProbeFailed: return 8;
1635                 case LDKEvent_PendingHTLCsForwardable: return 9;
1636                 case LDKEvent_SpendableOutputs: return 10;
1637                 case LDKEvent_PaymentForwarded: return 11;
1638                 case LDKEvent_ChannelClosed: return 12;
1639                 case LDKEvent_DiscardFunding: return 13;
1640                 case LDKEvent_OpenChannelRequest: return 14;
1641                 case LDKEvent_HTLCHandlingFailed: return 15;
1642                 default: abort();
1643         }
1644 }
1645 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_FundingGenerationReady);
1648                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1649                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1650         return temporary_channel_id_arr;
1651 }
1652 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_FundingGenerationReady);
1655                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1656                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1657         return counterparty_node_id_arr;
1658 }
1659 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_FundingGenerationReady);
1662                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1663         return channel_value_satoshis_conv;
1664 }
1665 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1666         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1667         assert(obj->tag == LDKEvent_FundingGenerationReady);
1668                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1669                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1670                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1671         return output_script_arr;
1672 }
1673 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1674         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1675         assert(obj->tag == LDKEvent_FundingGenerationReady);
1676                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1677         return user_channel_id_conv;
1678 }
1679 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1680         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1681         assert(obj->tag == LDKEvent_PaymentReceived);
1682                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1683                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1684         return payment_hash_arr;
1685 }
1686 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1687         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1688         assert(obj->tag == LDKEvent_PaymentReceived);
1689                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1690         return amount_msat_conv;
1691 }
1692 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1693         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1694         assert(obj->tag == LDKEvent_PaymentReceived);
1695                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1696         return purpose_ref;
1697 }
1698 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1699         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1700         assert(obj->tag == LDKEvent_PaymentClaimed);
1701                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1702                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1703         return payment_hash_arr;
1704 }
1705 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1706         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1707         assert(obj->tag == LDKEvent_PaymentClaimed);
1708                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1709         return amount_msat_conv;
1710 }
1711 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1712         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1713         assert(obj->tag == LDKEvent_PaymentClaimed);
1714                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1715         return purpose_ref;
1716 }
1717 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1718         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1719         assert(obj->tag == LDKEvent_PaymentSent);
1720                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1721                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1722         return payment_id_arr;
1723 }
1724 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1725         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1726         assert(obj->tag == LDKEvent_PaymentSent);
1727                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1728                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1729         return payment_preimage_arr;
1730 }
1731 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1732         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1733         assert(obj->tag == LDKEvent_PaymentSent);
1734                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1735                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1736         return payment_hash_arr;
1737 }
1738 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1739         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1740         assert(obj->tag == LDKEvent_PaymentSent);
1741                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1742         return fee_paid_msat_ref;
1743 }
1744 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1745         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1746         assert(obj->tag == LDKEvent_PaymentFailed);
1747                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1748                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1749         return payment_id_arr;
1750 }
1751 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1752         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1753         assert(obj->tag == LDKEvent_PaymentFailed);
1754                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1755                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1756         return payment_hash_arr;
1757 }
1758 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1759         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1760         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1761                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1762                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1763         return payment_id_arr;
1764 }
1765 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1766         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1767         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1768                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1769                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1770         return payment_hash_arr;
1771 }
1772 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1773         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1774         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1775                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1776                         uint32_tArray path_arr = NULL;
1777                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1778                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1779                         for (size_t k = 0; k < path_var.datalen; k++) {
1780                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1781                                 uint32_t path_conv_10_ref = 0;
1782                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1783                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1784                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1785                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1786                                 path_arr_ptr[k] = path_conv_10_ref;
1787                         }
1788                         
1789         return path_arr;
1790 }
1791 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1792         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1793         assert(obj->tag == LDKEvent_PaymentPathFailed);
1794                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1795                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1796         return payment_id_arr;
1797 }
1798 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1800         assert(obj->tag == LDKEvent_PaymentPathFailed);
1801                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1802                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1803         return payment_hash_arr;
1804 }
1805 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1806         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1807         assert(obj->tag == LDKEvent_PaymentPathFailed);
1808                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1809         return rejected_by_dest_conv;
1810 }
1811 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1812         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1813         assert(obj->tag == LDKEvent_PaymentPathFailed);
1814                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1815         return network_update_ref;
1816 }
1817 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1818         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1819         assert(obj->tag == LDKEvent_PaymentPathFailed);
1820                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1821         return all_paths_failed_conv;
1822 }
1823 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1824         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1825         assert(obj->tag == LDKEvent_PaymentPathFailed);
1826                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1827                         uint32_tArray path_arr = NULL;
1828                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1829                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1830                         for (size_t k = 0; k < path_var.datalen; k++) {
1831                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1832                                 uint32_t path_conv_10_ref = 0;
1833                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1836                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1837                                 path_arr_ptr[k] = path_conv_10_ref;
1838                         }
1839                         
1840         return path_arr;
1841 }
1842 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1843         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1844         assert(obj->tag == LDKEvent_PaymentPathFailed);
1845                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1846         return short_channel_id_ref;
1847 }
1848 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1849         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1850         assert(obj->tag == LDKEvent_PaymentPathFailed);
1851                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1852                         uint32_t retry_ref = 0;
1853                         if ((uintptr_t)retry_var.inner > 4096) {
1854                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1855                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1856                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1857                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1858                         }
1859         return retry_ref;
1860 }
1861 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_id"))) TS_LDKEvent_ProbeSuccessful_get_payment_id(uint32_t ptr) {
1862         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1863         assert(obj->tag == LDKEvent_ProbeSuccessful);
1864                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1865                         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
1866         return payment_id_arr;
1867 }
1868 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_hash"))) TS_LDKEvent_ProbeSuccessful_get_payment_hash(uint32_t ptr) {
1869         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1870         assert(obj->tag == LDKEvent_ProbeSuccessful);
1871                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1872                         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
1873         return payment_hash_arr;
1874 }
1875 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_path"))) TS_LDKEvent_ProbeSuccessful_get_path(uint32_t ptr) {
1876         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1877         assert(obj->tag == LDKEvent_ProbeSuccessful);
1878                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
1879                         uint32_tArray path_arr = NULL;
1880                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1881                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1882                         for (size_t k = 0; k < path_var.datalen; k++) {
1883                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1884                                 uint32_t path_conv_10_ref = 0;
1885                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1886                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1887                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1888                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1889                                 path_arr_ptr[k] = path_conv_10_ref;
1890                         }
1891                         
1892         return path_arr;
1893 }
1894 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_id"))) TS_LDKEvent_ProbeFailed_get_payment_id(uint32_t ptr) {
1895         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1896         assert(obj->tag == LDKEvent_ProbeFailed);
1897                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1898                         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
1899         return payment_id_arr;
1900 }
1901 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_hash"))) TS_LDKEvent_ProbeFailed_get_payment_hash(uint32_t ptr) {
1902         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1903         assert(obj->tag == LDKEvent_ProbeFailed);
1904                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1905                         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
1906         return payment_hash_arr;
1907 }
1908 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_path"))) TS_LDKEvent_ProbeFailed_get_path(uint32_t ptr) {
1909         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1910         assert(obj->tag == LDKEvent_ProbeFailed);
1911                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
1912                         uint32_tArray path_arr = NULL;
1913                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1914                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1915                         for (size_t k = 0; k < path_var.datalen; k++) {
1916                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1917                                 uint32_t path_conv_10_ref = 0;
1918                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1921                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1922                                 path_arr_ptr[k] = path_conv_10_ref;
1923                         }
1924                         
1925         return path_arr;
1926 }
1927 uint32_t __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_short_channel_id"))) TS_LDKEvent_ProbeFailed_get_short_channel_id(uint32_t ptr) {
1928         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1929         assert(obj->tag == LDKEvent_ProbeFailed);
1930                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
1931         return short_channel_id_ref;
1932 }
1933 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1934         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1935         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1936                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1937         return time_forwardable_conv;
1938 }
1939 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1940         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1941         assert(obj->tag == LDKEvent_SpendableOutputs);
1942                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1943                         uint32_tArray outputs_arr = NULL;
1944                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1945                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1946                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1947                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1948                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1949                         }
1950                         
1951         return outputs_arr;
1952 }
1953 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1954         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1955         assert(obj->tag == LDKEvent_PaymentForwarded);
1956                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1957                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1958         return prev_channel_id_arr;
1959 }
1960 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1961         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1962         assert(obj->tag == LDKEvent_PaymentForwarded);
1963                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1964                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1965         return next_channel_id_arr;
1966 }
1967 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1968         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1969         assert(obj->tag == LDKEvent_PaymentForwarded);
1970                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1971         return fee_earned_msat_ref;
1972 }
1973 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1974         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1975         assert(obj->tag == LDKEvent_PaymentForwarded);
1976                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1977         return claim_from_onchain_tx_conv;
1978 }
1979 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1980         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1981         assert(obj->tag == LDKEvent_ChannelClosed);
1982                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1983                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1984         return channel_id_arr;
1985 }
1986 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1987         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1988         assert(obj->tag == LDKEvent_ChannelClosed);
1989                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1990         return user_channel_id_conv;
1991 }
1992 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1993         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1994         assert(obj->tag == LDKEvent_ChannelClosed);
1995                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1996         return reason_ref;
1997 }
1998 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1999         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2000         assert(obj->tag == LDKEvent_DiscardFunding);
2001                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
2002                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
2003         return channel_id_arr;
2004 }
2005 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
2006         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2007         assert(obj->tag == LDKEvent_DiscardFunding);
2008                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2009                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
2010                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
2011         return transaction_arr;
2012 }
2013 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
2014         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2015         assert(obj->tag == LDKEvent_OpenChannelRequest);
2016                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
2017                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
2018         return temporary_channel_id_arr;
2019 }
2020 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
2021         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2022         assert(obj->tag == LDKEvent_OpenChannelRequest);
2023                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
2024                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
2025         return counterparty_node_id_arr;
2026 }
2027 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
2028         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2029         assert(obj->tag == LDKEvent_OpenChannelRequest);
2030                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2031         return funding_satoshis_conv;
2032 }
2033 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
2034         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2035         assert(obj->tag == LDKEvent_OpenChannelRequest);
2036                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2037         return push_msat_conv;
2038 }
2039 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
2040         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2041         assert(obj->tag == LDKEvent_OpenChannelRequest);
2042                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2043                         uint32_t channel_type_ref = 0;
2044                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2047                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2048         return channel_type_ref;
2049 }
2050 int8_tArray __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id"))) TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(uint32_t ptr) {
2051         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2052         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2053                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
2054                         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
2055         return prev_channel_id_arr;
2056 }
2057 uint32_t __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination"))) TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(uint32_t ptr) {
2058         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2059         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2060                         uint32_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2061         return failed_next_destination_ref;
2062 }
2063 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
2064         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2065         switch(obj->tag) {
2066                 case LDKCOption_EventZ_Some: return 0;
2067                 case LDKCOption_EventZ_None: return 1;
2068                 default: abort();
2069         }
2070 }
2071 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
2072         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2073         assert(obj->tag == LDKCOption_EventZ_Some);
2074                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
2075         return some_ref;
2076 }
2077 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2078 CHECK(owner->result_ok);
2079         return COption_EventZ_clone(&*owner->contents.result);
2080 }
2081 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
2082         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2083         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2084         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2085         uint32_t ret_ref = (uintptr_t)ret_copy;
2086         return ret_ref;
2087 }
2088
2089 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2090 CHECK(!owner->result_ok);
2091         return DecodeError_clone(&*owner->contents.err);
2092 }
2093 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
2094         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2095         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2096         uint32_t ret_ref = 0;
2097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2100         ret_ref = (uintptr_t)ret_var.inner;
2101         if (ret_var.is_owned) {
2102                 ret_ref |= 1;
2103         }
2104         return ret_ref;
2105 }
2106
2107 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2108         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2109         switch(obj->tag) {
2110                 case LDKErrorAction_DisconnectPeer: return 0;
2111                 case LDKErrorAction_IgnoreError: return 1;
2112                 case LDKErrorAction_IgnoreAndLog: return 2;
2113                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2114                 case LDKErrorAction_SendErrorMessage: return 4;
2115                 case LDKErrorAction_SendWarningMessage: return 5;
2116                 default: abort();
2117         }
2118 }
2119 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2120         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2121         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2122                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2123                         uint32_t msg_ref = 0;
2124                         if ((uintptr_t)msg_var.inner > 4096) {
2125                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2126                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2127                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2128                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2129                         }
2130         return msg_ref;
2131 }
2132 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2133         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2134         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2135                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2136         return ignore_and_log_conv;
2137 }
2138 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2139         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2140         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2141                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2142                         uint32_t msg_ref = 0;
2143                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2146                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2147         return msg_ref;
2148 }
2149 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
2150         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2151         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2152                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2153                         uint32_t msg_ref = 0;
2154                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2155                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2157                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2158         return msg_ref;
2159 }
2160 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2161         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2162         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2163                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2164         return log_level_conv;
2165 }
2166 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2167         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2168         switch(obj->tag) {
2169                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2170                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2171                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2172                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2173                 case LDKMessageSendEvent_SendChannelReady: return 4;
2174                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2175                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2176                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2177                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2178                 case LDKMessageSendEvent_SendShutdown: return 9;
2179                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2180                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2181                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2182                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2183                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2184                 case LDKMessageSendEvent_HandleError: return 15;
2185                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2186                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2187                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2188                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2189                 default: abort();
2190         }
2191 }
2192 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2193         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2194         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2195                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2196                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2197         return node_id_arr;
2198 }
2199 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2202                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2203                         uint32_t msg_ref = 0;
2204                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2205                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2206                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2207                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2208         return msg_ref;
2209 }
2210 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2211         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2212         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2213                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2214                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2215         return node_id_arr;
2216 }
2217 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2220                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2221                         uint32_t msg_ref = 0;
2222                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2223                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2224                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2225                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2226         return msg_ref;
2227 }
2228 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2229         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2230         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2231                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2232                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2233         return node_id_arr;
2234 }
2235 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2237         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2238                         LDKFundingCreated msg_var = obj->send_funding_created.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_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2247         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2248         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2249                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2250                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2251         return node_id_arr;
2252 }
2253 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2254         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2255         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2256                         LDKFundingSigned msg_var = obj->send_funding_signed.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_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2265         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2266         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2267                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2268                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2269         return node_id_arr;
2270 }
2271 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2272         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2273         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2274                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2275                         uint32_t msg_ref = 0;
2276                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2277                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2278                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2279                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2280         return msg_ref;
2281 }
2282 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2283         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2284         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2285                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2286                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2287         return node_id_arr;
2288 }
2289 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2290         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2291         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2292                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2293                         uint32_t msg_ref = 0;
2294                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2295                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2296                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2297                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2298         return msg_ref;
2299 }
2300 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2301         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2302         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2303                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2304                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2305         return node_id_arr;
2306 }
2307 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2308         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2309         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2310                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2311                         uint32_t updates_ref = 0;
2312                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2313                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2314                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2315                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2316         return updates_ref;
2317 }
2318 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2319         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2320         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2321                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2322                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2323         return node_id_arr;
2324 }
2325 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2326         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2327         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2328                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2329                         uint32_t msg_ref = 0;
2330                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2331                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2333                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2334         return msg_ref;
2335 }
2336 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2337         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2338         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2339                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2340                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2341         return node_id_arr;
2342 }
2343 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2344         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2345         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2346                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2347                         uint32_t msg_ref = 0;
2348                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2349                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2350                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2351                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2352         return msg_ref;
2353 }
2354 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2355         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2356         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2357                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2358                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2359         return node_id_arr;
2360 }
2361 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2362         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2363         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2364                         LDKShutdown msg_var = obj->send_shutdown.msg;
2365                         uint32_t msg_ref = 0;
2366                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2369                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2370         return msg_ref;
2371 }
2372 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2373         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2374         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2375                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2376                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2377         return node_id_arr;
2378 }
2379 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2380         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2381         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2382                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2383                         uint32_t msg_ref = 0;
2384                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2385                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2386                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2387                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2388         return msg_ref;
2389 }
2390 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2391         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2392         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2393                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2394                         uint32_t msg_ref = 0;
2395                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2396                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2397                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2398                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2399         return msg_ref;
2400 }
2401 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2402         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2403         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2404                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2405                         uint32_t update_msg_ref = 0;
2406                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2407                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2408                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2409                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2410         return update_msg_ref;
2411 }
2412 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2413         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2414         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2415                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2416                         uint32_t msg_ref = 0;
2417                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2418                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2419                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2420                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2421         return msg_ref;
2422 }
2423 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2424         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2425         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2426                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2427                         uint32_t msg_ref = 0;
2428                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2429                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2430                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2431                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2432         return msg_ref;
2433 }
2434 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2435         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2436         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2437                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2438                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2439         return node_id_arr;
2440 }
2441 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2442         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2443         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2444                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2445                         uint32_t msg_ref = 0;
2446                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2447                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2448                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2449                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2450         return msg_ref;
2451 }
2452 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2453         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2454         assert(obj->tag == LDKMessageSendEvent_HandleError);
2455                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2456                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2457         return node_id_arr;
2458 }
2459 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2460         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2461         assert(obj->tag == LDKMessageSendEvent_HandleError);
2462                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2463         return action_ref;
2464 }
2465 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2466         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2467         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2468                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2469                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2470         return node_id_arr;
2471 }
2472 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2473         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2474         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2475                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2476                         uint32_t msg_ref = 0;
2477                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2478                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2479                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2480                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2481         return msg_ref;
2482 }
2483 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2484         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2485         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2486                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2487                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2488         return node_id_arr;
2489 }
2490 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2491         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2492         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2493                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2494                         uint32_t msg_ref = 0;
2495                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2496                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2497                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2498                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2499         return msg_ref;
2500 }
2501 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2502         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2503         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2504                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2505                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2506         return node_id_arr;
2507 }
2508 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2509         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2510         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2511                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2512                         uint32_t msg_ref = 0;
2513                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2514                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2515                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2516                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2517         return msg_ref;
2518 }
2519 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2520         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2521         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2522                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2523                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2524         return node_id_arr;
2525 }
2526 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2527         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2528         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2529                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2530                         uint32_t msg_ref = 0;
2531                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2532                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2533                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2534                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2535         return msg_ref;
2536 }
2537 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2538         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2539         for (size_t i = 0; i < ret.datalen; i++) {
2540                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2541         }
2542         return ret;
2543 }
2544 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2545 CHECK(owner->result_ok);
2546         return TxOut_clone(&*owner->contents.result);
2547 }
2548 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2549         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2550         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2551         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2552         return (uint32_t)ret_ref;
2553 }
2554
2555 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2556 CHECK(!owner->result_ok);
2557         return AccessError_clone(&*owner->contents.err);
2558 }
2559 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2560         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2561         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2562         return ret_conv;
2563 }
2564
2565 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2566         return owner->a;
2567 }
2568 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2569         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2570         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2571         return ret_conv;
2572 }
2573
2574 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2575         return owner->b;
2576 }
2577 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2578         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2579         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2582         return ret_arr;
2583 }
2584
2585 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2586         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2587         for (size_t i = 0; i < ret.datalen; i++) {
2588                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2589         }
2590         return ret;
2591 }
2592 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2593         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2594         for (size_t i = 0; i < ret.datalen; i++) {
2595                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2596         }
2597         return ret;
2598 }
2599 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2600 CHECK(owner->result_ok);
2601         return *owner->contents.result;
2602 }
2603 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2604         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2605         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2606 }
2607
2608 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2609 CHECK(!owner->result_ok);
2610         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2611 }
2612 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2613         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2614         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2615         return ret_conv;
2616 }
2617
2618 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2619         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2620         switch(obj->tag) {
2621                 case LDKMonitorEvent_HTLCEvent: return 0;
2622                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2623                 case LDKMonitorEvent_UpdateCompleted: return 2;
2624                 case LDKMonitorEvent_UpdateFailed: return 3;
2625                 default: abort();
2626         }
2627 }
2628 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2629         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2630         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2631                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2632                         uint32_t htlc_event_ref = 0;
2633                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2634                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2635                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2636                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2637         return htlc_event_ref;
2638 }
2639 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2640         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2641         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2642                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2643                         uint32_t commitment_tx_confirmed_ref = 0;
2644                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2645                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2646                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2647                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2648         return commitment_tx_confirmed_ref;
2649 }
2650 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2651         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2652         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2653                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2654                         uint32_t funding_txo_ref = 0;
2655                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2656                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2658                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2659         return funding_txo_ref;
2660 }
2661 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2662         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2663         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2664                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2665         return monitor_update_id_conv;
2666 }
2667 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2668         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2669         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2670                         LDKOutPoint update_failed_var = obj->update_failed;
2671                         uint32_t update_failed_ref = 0;
2672                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2673                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2674                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2675                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2676         return update_failed_ref;
2677 }
2678 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2679         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2680         for (size_t i = 0; i < ret.datalen; i++) {
2681                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2682         }
2683         return ret;
2684 }
2685 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2686         return OutPoint_clone(&owner->a);
2687 }
2688 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(uint32_t owner) {
2689         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2690         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2691         uint32_t ret_ref = 0;
2692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2695         ret_ref = (uintptr_t)ret_var.inner;
2696         if (ret_var.is_owned) {
2697                 ret_ref |= 1;
2698         }
2699         return ret_ref;
2700 }
2701
2702 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2703         return CVec_MonitorEventZ_clone(&owner->b);
2704 }
2705 uint32_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(uint32_t owner) {
2706         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2707         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2708         uint32_tArray ret_arr = NULL;
2709         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2710         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
2711         for (size_t o = 0; o < ret_var.datalen; o++) {
2712                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2713                 *ret_conv_14_copy = ret_var.data[o];
2714                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2715                 ret_arr_ptr[o] = ret_conv_14_ref;
2716         }
2717         
2718         FREE(ret_var.data);
2719         return ret_arr;
2720 }
2721
2722 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2723         return owner->c;
2724 }
2725 int8_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(uint32_t owner) {
2726         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2727         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2728         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
2729         return ret_arr;
2730 }
2731
2732 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
2733         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
2734         for (size_t i = 0; i < ret.datalen; i++) {
2735                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
2736         }
2737         return ret;
2738 }
2739 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2740         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2741         switch(obj->tag) {
2742                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2743                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2744                 default: abort();
2745         }
2746 }
2747 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2748         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2749         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2750                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2751                         *some_conv = obj->some;
2752                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2753         return ((uint32_t)some_conv);
2754 }
2755 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2756 CHECK(owner->result_ok);
2757         return FixedPenaltyScorer_clone(&*owner->contents.result);
2758 }
2759 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2760         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2761         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2762         uint32_t ret_ref = 0;
2763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2766         ret_ref = (uintptr_t)ret_var.inner;
2767         if (ret_var.is_owned) {
2768                 ret_ref |= 1;
2769         }
2770         return ret_ref;
2771 }
2772
2773 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2774 CHECK(!owner->result_ok);
2775         return DecodeError_clone(&*owner->contents.err);
2776 }
2777 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2778         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2779         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2780         uint32_t ret_ref = 0;
2781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2784         ret_ref = (uintptr_t)ret_var.inner;
2785         if (ret_var.is_owned) {
2786                 ret_ref |= 1;
2787         }
2788         return ret_ref;
2789 }
2790
2791 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2792         return owner->a;
2793 }
2794 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint32_t owner) {
2795         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2796         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2797         return ret_conv;
2798 }
2799
2800 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2801         return owner->b;
2802 }
2803 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint32_t owner) {
2804         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2805         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2806         return ret_conv;
2807 }
2808
2809 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint32_t ptr) {
2810         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2811         switch(obj->tag) {
2812                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2813                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2814                 default: abort();
2815         }
2816 }
2817 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint32_t ptr) {
2818         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2819         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2820                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2821                         *some_conv = obj->some;
2822                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2823         return ((uint32_t)some_conv);
2824 }
2825 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2826         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2827         for (size_t i = 0; i < ret.datalen; i++) {
2828                 ret.data[i] = NodeId_clone(&orig->data[i]);
2829         }
2830         return ret;
2831 }
2832 typedef struct LDKLogger_JCalls {
2833         atomic_size_t refcnt;
2834         uint32_t instance_ptr;
2835 } LDKLogger_JCalls;
2836 static void LDKLogger_JCalls_free(void* this_arg) {
2837         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2838         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2839                 FREE(j_calls);
2840         }
2841 }
2842 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2843         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2844         LDKRecord record_var = *record;
2845         uint32_t record_ref = 0;
2846         record_var = Record_clone(&record_var);
2847         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2848         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2849         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2850         record_ref = (uintptr_t)record_var.inner;
2851         if (record_var.is_owned) {
2852                 record_ref |= 1;
2853         }
2854         js_invoke_function_u_u(j_calls->instance_ptr, 0, (uint32_t)record_ref);
2855 }
2856 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2857         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2858         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2859 }
2860 static inline LDKLogger LDKLogger_init (JSValue o) {
2861         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2862         atomic_init(&calls->refcnt, 1);
2863         calls->instance_ptr = o;
2864
2865         LDKLogger ret = {
2866                 .this_arg = (void*) calls,
2867                 .log = log_LDKLogger_jcall,
2868                 .free = LDKLogger_JCalls_free,
2869         };
2870         return ret;
2871 }
2872 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2873         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2874         *res_ptr = LDKLogger_init(o);
2875         return (long)res_ptr;
2876 }
2877 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2878 CHECK(owner->result_ok);
2879         return &*owner->contents.result;
2880 }
2881 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2882         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2883         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2884         uint32_t ret_ref = 0;
2885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2888         ret_ref = (uintptr_t)ret_var.inner & ~1;
2889         return ret_ref;
2890 }
2891
2892 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2893 CHECK(!owner->result_ok);
2894         return DecodeError_clone(&*owner->contents.err);
2895 }
2896 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2897         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2898         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2899         uint32_t ret_ref = 0;
2900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2903         ret_ref = (uintptr_t)ret_var.inner;
2904         if (ret_var.is_owned) {
2905                 ret_ref |= 1;
2906         }
2907         return ret_ref;
2908 }
2909
2910 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2911 CHECK(owner->result_ok);
2912         return InitFeatures_clone(&*owner->contents.result);
2913 }
2914 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2915         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2916         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2917         uint32_t ret_ref = 0;
2918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2921         ret_ref = (uintptr_t)ret_var.inner;
2922         if (ret_var.is_owned) {
2923                 ret_ref |= 1;
2924         }
2925         return ret_ref;
2926 }
2927
2928 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2929 CHECK(!owner->result_ok);
2930         return DecodeError_clone(&*owner->contents.err);
2931 }
2932 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2933         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2934         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2935         uint32_t ret_ref = 0;
2936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2939         ret_ref = (uintptr_t)ret_var.inner;
2940         if (ret_var.is_owned) {
2941                 ret_ref |= 1;
2942         }
2943         return ret_ref;
2944 }
2945
2946 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2947 CHECK(owner->result_ok);
2948         return ChannelFeatures_clone(&*owner->contents.result);
2949 }
2950 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2951         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2952         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2953         uint32_t ret_ref = 0;
2954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2957         ret_ref = (uintptr_t)ret_var.inner;
2958         if (ret_var.is_owned) {
2959                 ret_ref |= 1;
2960         }
2961         return ret_ref;
2962 }
2963
2964 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2965 CHECK(!owner->result_ok);
2966         return DecodeError_clone(&*owner->contents.err);
2967 }
2968 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2969         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2970         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2971         uint32_t ret_ref = 0;
2972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2975         ret_ref = (uintptr_t)ret_var.inner;
2976         if (ret_var.is_owned) {
2977                 ret_ref |= 1;
2978         }
2979         return ret_ref;
2980 }
2981
2982 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2983 CHECK(owner->result_ok);
2984         return NodeFeatures_clone(&*owner->contents.result);
2985 }
2986 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2987         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2988         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2989         uint32_t ret_ref = 0;
2990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2993         ret_ref = (uintptr_t)ret_var.inner;
2994         if (ret_var.is_owned) {
2995                 ret_ref |= 1;
2996         }
2997         return ret_ref;
2998 }
2999
3000 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3001 CHECK(!owner->result_ok);
3002         return DecodeError_clone(&*owner->contents.err);
3003 }
3004 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3005         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3006         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3007         uint32_t ret_ref = 0;
3008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3011         ret_ref = (uintptr_t)ret_var.inner;
3012         if (ret_var.is_owned) {
3013                 ret_ref |= 1;
3014         }
3015         return ret_ref;
3016 }
3017
3018 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3019 CHECK(owner->result_ok);
3020         return InvoiceFeatures_clone(&*owner->contents.result);
3021 }
3022 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3023         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3024         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3025         uint32_t ret_ref = 0;
3026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3029         ret_ref = (uintptr_t)ret_var.inner;
3030         if (ret_var.is_owned) {
3031                 ret_ref |= 1;
3032         }
3033         return ret_ref;
3034 }
3035
3036 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3037 CHECK(!owner->result_ok);
3038         return DecodeError_clone(&*owner->contents.err);
3039 }
3040 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3041         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3042         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3043         uint32_t ret_ref = 0;
3044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3047         ret_ref = (uintptr_t)ret_var.inner;
3048         if (ret_var.is_owned) {
3049                 ret_ref |= 1;
3050         }
3051         return ret_ref;
3052 }
3053
3054 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3055 CHECK(owner->result_ok);
3056         return ChannelTypeFeatures_clone(&*owner->contents.result);
3057 }
3058 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3059         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3060         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3061         uint32_t ret_ref = 0;
3062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3065         ret_ref = (uintptr_t)ret_var.inner;
3066         if (ret_var.is_owned) {
3067                 ret_ref |= 1;
3068         }
3069         return ret_ref;
3070 }
3071
3072 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3073 CHECK(!owner->result_ok);
3074         return DecodeError_clone(&*owner->contents.err);
3075 }
3076 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3077         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3078         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3079         uint32_t ret_ref = 0;
3080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3083         ret_ref = (uintptr_t)ret_var.inner;
3084         if (ret_var.is_owned) {
3085                 ret_ref |= 1;
3086         }
3087         return ret_ref;
3088 }
3089
3090 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3091 CHECK(owner->result_ok);
3092         return NodeId_clone(&*owner->contents.result);
3093 }
3094 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3095         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3096         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3097         uint32_t ret_ref = 0;
3098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3101         ret_ref = (uintptr_t)ret_var.inner;
3102         if (ret_var.is_owned) {
3103                 ret_ref |= 1;
3104         }
3105         return ret_ref;
3106 }
3107
3108 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3109 CHECK(!owner->result_ok);
3110         return DecodeError_clone(&*owner->contents.err);
3111 }
3112 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3113         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3114         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3115         uint32_t ret_ref = 0;
3116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3119         ret_ref = (uintptr_t)ret_var.inner;
3120         if (ret_var.is_owned) {
3121                 ret_ref |= 1;
3122         }
3123         return ret_ref;
3124 }
3125
3126 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3127 CHECK(owner->result_ok);
3128         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3129 }
3130 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3131         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3132         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3133         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3134         uint32_t ret_ref = (uintptr_t)ret_copy;
3135         return ret_ref;
3136 }
3137
3138 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3139 CHECK(!owner->result_ok);
3140         return DecodeError_clone(&*owner->contents.err);
3141 }
3142 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3143         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3144         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3145         uint32_t ret_ref = 0;
3146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3149         ret_ref = (uintptr_t)ret_var.inner;
3150         if (ret_var.is_owned) {
3151                 ret_ref |= 1;
3152         }
3153         return ret_ref;
3154 }
3155
3156 typedef struct LDKAccess_JCalls {
3157         atomic_size_t refcnt;
3158         uint32_t instance_ptr;
3159 } LDKAccess_JCalls;
3160 static void LDKAccess_JCalls_free(void* this_arg) {
3161         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3162         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3163                 FREE(j_calls);
3164         }
3165 }
3166 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3167         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3168         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3169         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3170         int64_t short_channel_id_conv = short_channel_id;
3171         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
3172         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3173         CHECK_ACCESS(ret_ptr);
3174         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3175         FREE((void*)ret);
3176         return ret_conv;
3177 }
3178 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3179         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3180         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3181 }
3182 static inline LDKAccess LDKAccess_init (JSValue o) {
3183         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3184         atomic_init(&calls->refcnt, 1);
3185         calls->instance_ptr = o;
3186
3187         LDKAccess ret = {
3188                 .this_arg = (void*) calls,
3189                 .get_utxo = get_utxo_LDKAccess_jcall,
3190                 .free = LDKAccess_JCalls_free,
3191         };
3192         return ret;
3193 }
3194 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3195         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3196         *res_ptr = LDKAccess_init(o);
3197         return (long)res_ptr;
3198 }
3199 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) {
3200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3202         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3203         unsigned char genesis_hash_arr[32];
3204         CHECK(genesis_hash->arr_len == 32);
3205         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3206         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3207         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3208         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3209         return (uint32_t)ret_conv;
3210 }
3211
3212 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3213         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3214         switch(obj->tag) {
3215                 case LDKCOption_AccessZ_Some: return 0;
3216                 case LDKCOption_AccessZ_None: return 1;
3217                 default: abort();
3218         }
3219 }
3220 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3221         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3222         assert(obj->tag == LDKCOption_AccessZ_Some);
3223                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3224                         *some_ret = obj->some;
3225                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3226                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3227                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3228                                 LDKAccess_JCalls_cloned(&(*some_ret));
3229                         }
3230         return (uint32_t)some_ret;
3231 }
3232 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3233 CHECK(owner->result_ok);
3234         return *owner->contents.result;
3235 }
3236 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3237         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3238         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3239         return ret_conv;
3240 }
3241
3242 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3243 CHECK(!owner->result_ok);
3244         return LightningError_clone(&*owner->contents.err);
3245 }
3246 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3247         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3248         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3249         uint32_t ret_ref = 0;
3250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3253         ret_ref = (uintptr_t)ret_var.inner;
3254         if (ret_var.is_owned) {
3255                 ret_ref |= 1;
3256         }
3257         return ret_ref;
3258 }
3259
3260 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3261         return ChannelAnnouncement_clone(&owner->a);
3262 }
3263 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3264         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3265         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3266         uint32_t ret_ref = 0;
3267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3270         ret_ref = (uintptr_t)ret_var.inner;
3271         if (ret_var.is_owned) {
3272                 ret_ref |= 1;
3273         }
3274         return ret_ref;
3275 }
3276
3277 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3278         return ChannelUpdate_clone(&owner->b);
3279 }
3280 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3281         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3282         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3283         uint32_t ret_ref = 0;
3284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3287         ret_ref = (uintptr_t)ret_var.inner;
3288         if (ret_var.is_owned) {
3289                 ret_ref |= 1;
3290         }
3291         return ret_ref;
3292 }
3293
3294 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3295         return ChannelUpdate_clone(&owner->c);
3296 }
3297 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3298         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3299         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3300         uint32_t ret_ref = 0;
3301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3304         ret_ref = (uintptr_t)ret_var.inner;
3305         if (ret_var.is_owned) {
3306                 ret_ref |= 1;
3307         }
3308         return ret_ref;
3309 }
3310
3311 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3312         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3313         for (size_t i = 0; i < ret.datalen; i++) {
3314                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3315         }
3316         return ret;
3317 }
3318 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3319         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3320         for (size_t i = 0; i < ret.datalen; i++) {
3321                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3322         }
3323         return ret;
3324 }
3325 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3326 CHECK(owner->result_ok);
3327         return *owner->contents.result;
3328 }
3329 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3330         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3331         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3332 }
3333
3334 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3335 CHECK(!owner->result_ok);
3336         return LightningError_clone(&*owner->contents.err);
3337 }
3338 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3339         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3340         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3341         uint32_t ret_ref = 0;
3342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3345         ret_ref = (uintptr_t)ret_var.inner;
3346         if (ret_var.is_owned) {
3347                 ret_ref |= 1;
3348         }
3349         return ret_ref;
3350 }
3351
3352 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(owner->result_ok);
3354         return ChannelUpdateInfo_clone(&*owner->contents.result);
3355 }
3356 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3357         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3358         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3359         uint32_t ret_ref = 0;
3360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3363         ret_ref = (uintptr_t)ret_var.inner;
3364         if (ret_var.is_owned) {
3365                 ret_ref |= 1;
3366         }
3367         return ret_ref;
3368 }
3369
3370 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3371 CHECK(!owner->result_ok);
3372         return DecodeError_clone(&*owner->contents.err);
3373 }
3374 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3375         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3376         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3377         uint32_t ret_ref = 0;
3378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3381         ret_ref = (uintptr_t)ret_var.inner;
3382         if (ret_var.is_owned) {
3383                 ret_ref |= 1;
3384         }
3385         return ret_ref;
3386 }
3387
3388 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(owner->result_ok);
3390         return ChannelInfo_clone(&*owner->contents.result);
3391 }
3392 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3393         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3394         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3395         uint32_t ret_ref = 0;
3396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3399         ret_ref = (uintptr_t)ret_var.inner;
3400         if (ret_var.is_owned) {
3401                 ret_ref |= 1;
3402         }
3403         return ret_ref;
3404 }
3405
3406 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3407 CHECK(!owner->result_ok);
3408         return DecodeError_clone(&*owner->contents.err);
3409 }
3410 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3411         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3412         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3413         uint32_t ret_ref = 0;
3414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3417         ret_ref = (uintptr_t)ret_var.inner;
3418         if (ret_var.is_owned) {
3419                 ret_ref |= 1;
3420         }
3421         return ret_ref;
3422 }
3423
3424 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3425 CHECK(owner->result_ok);
3426         return RoutingFees_clone(&*owner->contents.result);
3427 }
3428 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3429         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3430         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3431         uint32_t ret_ref = 0;
3432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3435         ret_ref = (uintptr_t)ret_var.inner;
3436         if (ret_var.is_owned) {
3437                 ret_ref |= 1;
3438         }
3439         return ret_ref;
3440 }
3441
3442 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3443 CHECK(!owner->result_ok);
3444         return DecodeError_clone(&*owner->contents.err);
3445 }
3446 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3447         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3448         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3449         uint32_t ret_ref = 0;
3450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3453         ret_ref = (uintptr_t)ret_var.inner;
3454         if (ret_var.is_owned) {
3455                 ret_ref |= 1;
3456         }
3457         return ret_ref;
3458 }
3459
3460 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3461         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3462         switch(obj->tag) {
3463                 case LDKNetAddress_IPv4: return 0;
3464                 case LDKNetAddress_IPv6: return 1;
3465                 case LDKNetAddress_OnionV2: return 2;
3466                 case LDKNetAddress_OnionV3: return 3;
3467                 case LDKNetAddress_Hostname: return 4;
3468                 default: abort();
3469         }
3470 }
3471 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3472         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3473         assert(obj->tag == LDKNetAddress_IPv4);
3474                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3475                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3476         return addr_arr;
3477 }
3478 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3479         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3480         assert(obj->tag == LDKNetAddress_IPv4);
3481                         int16_t port_conv = obj->i_pv4.port;
3482         return port_conv;
3483 }
3484 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3485         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3486         assert(obj->tag == LDKNetAddress_IPv6);
3487                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3488                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3489         return addr_arr;
3490 }
3491 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3492         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3493         assert(obj->tag == LDKNetAddress_IPv6);
3494                         int16_t port_conv = obj->i_pv6.port;
3495         return port_conv;
3496 }
3497 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3498         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3499         assert(obj->tag == LDKNetAddress_OnionV2);
3500                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3501                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3502         return onion_v2_arr;
3503 }
3504 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3505         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3506         assert(obj->tag == LDKNetAddress_OnionV3);
3507                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3508                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3509         return ed25519_pubkey_arr;
3510 }
3511 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3512         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3513         assert(obj->tag == LDKNetAddress_OnionV3);
3514                         int16_t checksum_conv = obj->onion_v3.checksum;
3515         return checksum_conv;
3516 }
3517 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3518         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3519         assert(obj->tag == LDKNetAddress_OnionV3);
3520                         int8_t version_conv = obj->onion_v3.version;
3521         return version_conv;
3522 }
3523 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3524         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3525         assert(obj->tag == LDKNetAddress_OnionV3);
3526                         int16_t port_conv = obj->onion_v3.port;
3527         return port_conv;
3528 }
3529 uint32_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_hostname"))) TS_LDKNetAddress_Hostname_get_hostname(uint32_t ptr) {
3530         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3531         assert(obj->tag == LDKNetAddress_Hostname);
3532                         LDKHostname hostname_var = obj->hostname.hostname;
3533                         uint32_t hostname_ref = 0;
3534                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3535                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3536                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
3537                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
3538         return hostname_ref;
3539 }
3540 int16_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_port"))) TS_LDKNetAddress_Hostname_get_port(uint32_t ptr) {
3541         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3542         assert(obj->tag == LDKNetAddress_Hostname);
3543                         int16_t port_conv = obj->hostname.port;
3544         return port_conv;
3545 }
3546 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3547         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3548         for (size_t i = 0; i < ret.datalen; i++) {
3549                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3550         }
3551         return ret;
3552 }
3553 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3554 CHECK(owner->result_ok);
3555         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3556 }
3557 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3558         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3559         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3560         uint32_t ret_ref = 0;
3561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3564         ret_ref = (uintptr_t)ret_var.inner;
3565         if (ret_var.is_owned) {
3566                 ret_ref |= 1;
3567         }
3568         return ret_ref;
3569 }
3570
3571 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3572 CHECK(!owner->result_ok);
3573         return DecodeError_clone(&*owner->contents.err);
3574 }
3575 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3576         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3577         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3578         uint32_t ret_ref = 0;
3579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3582         ret_ref = (uintptr_t)ret_var.inner;
3583         if (ret_var.is_owned) {
3584                 ret_ref |= 1;
3585         }
3586         return ret_ref;
3587 }
3588
3589 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3590 CHECK(owner->result_ok);
3591         return NodeAlias_clone(&*owner->contents.result);
3592 }
3593 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint32_t owner) {
3594         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3595         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3596         uint32_t ret_ref = 0;
3597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3600         ret_ref = (uintptr_t)ret_var.inner;
3601         if (ret_var.is_owned) {
3602                 ret_ref |= 1;
3603         }
3604         return ret_ref;
3605 }
3606
3607 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3608 CHECK(!owner->result_ok);
3609         return DecodeError_clone(&*owner->contents.err);
3610 }
3611 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint32_t owner) {
3612         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3613         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
3614         uint32_t ret_ref = 0;
3615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3618         ret_ref = (uintptr_t)ret_var.inner;
3619         if (ret_var.is_owned) {
3620                 ret_ref |= 1;
3621         }
3622         return ret_ref;
3623 }
3624
3625 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3626 CHECK(owner->result_ok);
3627         return NodeInfo_clone(&*owner->contents.result);
3628 }
3629 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3630         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3631         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3632         uint32_t ret_ref = 0;
3633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3636         ret_ref = (uintptr_t)ret_var.inner;
3637         if (ret_var.is_owned) {
3638                 ret_ref |= 1;
3639         }
3640         return ret_ref;
3641 }
3642
3643 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3644 CHECK(!owner->result_ok);
3645         return DecodeError_clone(&*owner->contents.err);
3646 }
3647 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3648         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3649         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3650         uint32_t ret_ref = 0;
3651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3654         ret_ref = (uintptr_t)ret_var.inner;
3655         if (ret_var.is_owned) {
3656                 ret_ref |= 1;
3657         }
3658         return ret_ref;
3659 }
3660
3661 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3662 CHECK(owner->result_ok);
3663         return &*owner->contents.result;
3664 }
3665 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3666         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3667         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3668         uint32_t ret_ref = 0;
3669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3672         ret_ref = (uintptr_t)ret_var.inner & ~1;
3673         return ret_ref;
3674 }
3675
3676 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3677 CHECK(!owner->result_ok);
3678         return DecodeError_clone(&*owner->contents.err);
3679 }
3680 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3681         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3682         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3683         uint32_t ret_ref = 0;
3684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3687         ret_ref = (uintptr_t)ret_var.inner;
3688         if (ret_var.is_owned) {
3689                 ret_ref |= 1;
3690         }
3691         return ret_ref;
3692 }
3693
3694 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3695         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3696         switch(obj->tag) {
3697                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3698                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3699                 default: abort();
3700         }
3701 }
3702 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3703         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3704         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3705                         LDKCVec_NetAddressZ some_var = obj->some;
3706                         uint32_tArray some_arr = NULL;
3707                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3708                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
3709                         for (size_t m = 0; m < some_var.datalen; m++) {
3710                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3711                                 some_arr_ptr[m] = some_conv_12_ref;
3712                         }
3713                         
3714         return some_arr;
3715 }
3716 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3717 CHECK(owner->result_ok);
3718         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3719 }
3720 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3721         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3722         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3723         uint32_t ret_ref = 0;
3724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3727         ret_ref = (uintptr_t)ret_var.inner;
3728         if (ret_var.is_owned) {
3729                 ret_ref |= 1;
3730         }
3731         return ret_ref;
3732 }
3733
3734 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3735 CHECK(!owner->result_ok);
3736         return DecodeError_clone(&*owner->contents.err);
3737 }
3738 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3739         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3740         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3741         uint32_t ret_ref = 0;
3742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3745         ret_ref = (uintptr_t)ret_var.inner;
3746         if (ret_var.is_owned) {
3747                 ret_ref |= 1;
3748         }
3749         return ret_ref;
3750 }
3751
3752 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3753 CHECK(owner->result_ok);
3754         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3755 }
3756 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3757         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3758         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3759         uint32_t ret_ref = 0;
3760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3763         ret_ref = (uintptr_t)ret_var.inner;
3764         if (ret_var.is_owned) {
3765                 ret_ref |= 1;
3766         }
3767         return ret_ref;
3768 }
3769
3770 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3771 CHECK(!owner->result_ok);
3772         return DecodeError_clone(&*owner->contents.err);
3773 }
3774 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3775         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3776         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3777         uint32_t ret_ref = 0;
3778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3781         ret_ref = (uintptr_t)ret_var.inner;
3782         if (ret_var.is_owned) {
3783                 ret_ref |= 1;
3784         }
3785         return ret_ref;
3786 }
3787
3788 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3789 CHECK(owner->result_ok);
3790         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3791 }
3792 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3793         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3794         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3795         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3796         uint32_t ret_ref = (uintptr_t)ret_copy;
3797         return ret_ref;
3798 }
3799
3800 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3801 CHECK(!owner->result_ok);
3802         return DecodeError_clone(&*owner->contents.err);
3803 }
3804 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3805         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3806         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3807         uint32_t ret_ref = 0;
3808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3811         ret_ref = (uintptr_t)ret_var.inner;
3812         if (ret_var.is_owned) {
3813                 ret_ref |= 1;
3814         }
3815         return ret_ref;
3816 }
3817
3818 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3819         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3820         for (size_t i = 0; i < ret.datalen; i++) {
3821                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3822         }
3823         return ret;
3824 }
3825 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3826         return owner->a;
3827 }
3828 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3829         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3830         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3831         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3832         return ret_arr;
3833 }
3834
3835 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3836         return owner->b;
3837 }
3838 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3839         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3840         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3841         ptrArray ret_arr = NULL;
3842         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3843         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3844         for (size_t m = 0; m < ret_var.datalen; m++) {
3845                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3846                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3847                 ret_arr_ptr[m] = ret_conv_12_arr;
3848         }
3849         
3850         return ret_arr;
3851 }
3852
3853 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3854 CHECK(owner->result_ok);
3855         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3856 }
3857 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3858         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3859         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3860         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3861         return ((uint32_t)ret_conv);
3862 }
3863
3864 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3865 CHECK(!owner->result_ok);
3866         return *owner->contents.err;
3867 }
3868 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3869         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3870         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3871 }
3872
3873 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3874 CHECK(owner->result_ok);
3875         return *owner->contents.result;
3876 }
3877 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3878         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3879         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3880         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3881         return ret_arr;
3882 }
3883
3884 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3885 CHECK(!owner->result_ok);
3886         return *owner->contents.err;
3887 }
3888 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3889         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3890         CResult_SignatureNoneZ_get_err(owner_conv);
3891 }
3892
3893 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3894         return owner->a;
3895 }
3896 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3897         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3898         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3899         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3900         return ret_arr;
3901 }
3902
3903 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3904         return owner->b;
3905 }
3906 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3907         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3908         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3909         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3910         return ret_arr;
3911 }
3912
3913 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3914 CHECK(owner->result_ok);
3915         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3916 }
3917 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3918         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3919         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3920         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3921         return ((uint32_t)ret_conv);
3922 }
3923
3924 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3925 CHECK(!owner->result_ok);
3926         return *owner->contents.err;
3927 }
3928 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3929         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3930         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3931 }
3932
3933 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3934 CHECK(owner->result_ok);
3935         return *owner->contents.result;
3936 }
3937 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3938         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3939         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3940         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3941         return ret_arr;
3942 }
3943
3944 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3945 CHECK(!owner->result_ok);
3946         return *owner->contents.err;
3947 }
3948 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3949         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3950         CResult_SecretKeyNoneZ_get_err(owner_conv);
3951 }
3952
3953 typedef struct LDKBaseSign_JCalls {
3954         atomic_size_t refcnt;
3955         uint32_t instance_ptr;
3956 } LDKBaseSign_JCalls;
3957 static void LDKBaseSign_JCalls_free(void* this_arg) {
3958         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3959         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3960                 FREE(j_calls);
3961         }
3962 }
3963 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3964         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3965         int64_t idx_conv = idx;
3966         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 2, (uint32_t)idx_conv);
3967         LDKPublicKey ret_ref;
3968         CHECK(ret->arr_len == 33);
3969         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3970         return ret_ref;
3971 }
3972 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3973         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3974         int64_t idx_conv = idx;
3975         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 3, (uint32_t)idx_conv);
3976         LDKThirtyTwoBytes ret_ref;
3977         CHECK(ret->arr_len == 32);
3978         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3979         return ret_ref;
3980 }
3981 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3983         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3984         uint32_t holder_tx_ref = 0;
3985         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3986         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3987         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3988         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3989         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3990         if (holder_tx_var.is_owned) {
3991                 holder_tx_ref |= 1;
3992         }
3993         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3994         ptrArray preimages_arr = NULL;
3995         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3996         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3997         for (size_t m = 0; m < preimages_var.datalen; m++) {
3998                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3999                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4000                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4001         }
4002         
4003         FREE(preimages_var.data);
4004         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 4, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
4005         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4006         CHECK_ACCESS(ret_ptr);
4007         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4008         FREE((void*)ret);
4009         return ret_conv;
4010 }
4011 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4012         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4013         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 5);
4014         LDKThirtyTwoBytes ret_ref;
4015         CHECK(ret->arr_len == 32);
4016         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4017         return ret_ref;
4018 }
4019 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4020         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4021         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4022         uint32_t commitment_tx_ref = 0;
4023         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4024         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4025         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4026         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4027         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4028         if (commitment_tx_var.is_owned) {
4029                 commitment_tx_ref |= 1;
4030         }
4031         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4032         ptrArray preimages_arr = NULL;
4033         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
4034         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
4035         for (size_t m = 0; m < preimages_var.datalen; m++) {
4036                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
4037                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4038                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4039         }
4040         
4041         FREE(preimages_var.data);
4042         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
4043         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4044         CHECK_ACCESS(ret_ptr);
4045         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4046         FREE((void*)ret);
4047         return ret_conv;
4048 }
4049 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4050         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4051         int64_t idx_conv = idx;
4052         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
4053         memcpy(secret_arr->elems, *secret, 32);
4054         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr);
4055         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4056         CHECK_ACCESS(ret_ptr);
4057         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4058         FREE((void*)ret);
4059         return ret_conv;
4060 }
4061 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4062         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4063         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4064         uint32_t commitment_tx_ref = 0;
4065         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4066         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4067         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4068         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4069         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4070         if (commitment_tx_var.is_owned) {
4071                 commitment_tx_ref |= 1;
4072         }
4073         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref);
4074         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4075         CHECK_ACCESS(ret_ptr);
4076         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4077         FREE((void*)ret);
4078         return ret_conv;
4079 }
4080 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]) {
4081         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4082         LDKTransaction justice_tx_var = justice_tx;
4083         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4084         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4085         Transaction_free(justice_tx_var);
4086         uint32_t input_conv = input;
4087         int64_t amount_conv = amount;
4088         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4089         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4090         uint32_t ret = js_invoke_function_u_uuuu(j_calls->instance_ptr, 9, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr);
4091         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4092         CHECK_ACCESS(ret_ptr);
4093         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4094         FREE((void*)ret);
4095         return ret_conv;
4096 }
4097 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) {
4098         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4099         LDKTransaction justice_tx_var = justice_tx;
4100         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4101         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4102         Transaction_free(justice_tx_var);
4103         uint32_t input_conv = input;
4104         int64_t amount_conv = amount;
4105         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4106         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4107         LDKHTLCOutputInCommitment htlc_var = *htlc;
4108         uint32_t htlc_ref = 0;
4109         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4110         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4111         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4112         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4113         htlc_ref = (uintptr_t)htlc_var.inner;
4114         if (htlc_var.is_owned) {
4115                 htlc_ref |= 1;
4116         }
4117         uint32_t ret = js_invoke_function_u_uuuuu(j_calls->instance_ptr, 10, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
4118         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4119         CHECK_ACCESS(ret_ptr);
4120         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4121         FREE((void*)ret);
4122         return ret_conv;
4123 }
4124 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) {
4125         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4126         LDKTransaction htlc_tx_var = htlc_tx;
4127         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
4128         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
4129         Transaction_free(htlc_tx_var);
4130         uint32_t input_conv = input;
4131         int64_t amount_conv = amount;
4132         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
4133         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
4134         LDKHTLCOutputInCommitment htlc_var = *htlc;
4135         uint32_t htlc_ref = 0;
4136         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4137         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4138         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4139         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4140         htlc_ref = (uintptr_t)htlc_var.inner;
4141         if (htlc_var.is_owned) {
4142                 htlc_ref |= 1;
4143         }
4144         uint32_t ret = js_invoke_function_u_uuuuu(j_calls->instance_ptr, 11, (uint32_t)htlc_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
4145         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4146         CHECK_ACCESS(ret_ptr);
4147         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4148         FREE((void*)ret);
4149         return ret_conv;
4150 }
4151 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4152         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4153         LDKClosingTransaction closing_tx_var = *closing_tx;
4154         uint32_t closing_tx_ref = 0;
4155         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4156         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4157         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4158         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4159         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4160         if (closing_tx_var.is_owned) {
4161                 closing_tx_ref |= 1;
4162         }
4163         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref);
4164         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4165         CHECK_ACCESS(ret_ptr);
4166         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4167         FREE((void*)ret);
4168         return ret_conv;
4169 }
4170 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4171         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4172         LDKUnsignedChannelAnnouncement msg_var = *msg;
4173         uint32_t msg_ref = 0;
4174         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4175         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4176         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4178         msg_ref = (uintptr_t)msg_var.inner;
4179         if (msg_var.is_owned) {
4180                 msg_ref |= 1;
4181         }
4182         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 13, (uint32_t)msg_ref);
4183         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4184         CHECK_ACCESS(ret_ptr);
4185         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4186         FREE((void*)ret);
4187         return ret_conv;
4188 }
4189 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4190         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4191         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4192         uint32_t channel_parameters_ref = 0;
4193         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4194         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4195         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4196         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4197         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4198         if (channel_parameters_var.is_owned) {
4199                 channel_parameters_ref |= 1;
4200         }
4201         js_invoke_function_u_u(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref);
4202 }
4203 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
4204         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
4205         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4206 }
4207 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
4208         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4209         atomic_init(&calls->refcnt, 1);
4210         calls->instance_ptr = o;
4211
4212         LDKChannelPublicKeys pubkeys_conv;
4213         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4214         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4216
4217         LDKBaseSign ret = {
4218                 .this_arg = (void*) calls,
4219                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4220                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4221                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4222                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4223                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4224                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4225                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4226                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4227                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4228                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4229                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4230                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4231                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4232                 .free = LDKBaseSign_JCalls_free,
4233                 .pubkeys = pubkeys_conv,
4234                 .set_pubkeys = NULL,
4235         };
4236         return ret;
4237 }
4238 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
4239         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4240         *res_ptr = LDKBaseSign_init(o, pubkeys);
4241         return (long)res_ptr;
4242 }
4243 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
4244         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4245         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4246         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4247         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
4248         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
4249         return ret_arr;
4250 }
4251
4252 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
4253         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4254         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4255         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4256         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4257         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4258         return ret_arr;
4259 }
4260
4261 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) {
4262         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4265         LDKHolderCommitmentTransaction holder_tx_conv;
4266         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4267         holder_tx_conv.is_owned = false;
4268         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4269         LDKCVec_PaymentPreimageZ preimages_constr;
4270         preimages_constr.datalen = preimages->arr_len;
4271         if (preimages_constr.datalen > 0)
4272                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4273         else
4274                 preimages_constr.data = NULL;
4275         int8_tArray* preimages_vals = (void*) preimages->elems;
4276         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4277                 int8_tArray preimages_conv_12 = preimages_vals[m];
4278                 LDKThirtyTwoBytes preimages_conv_12_ref;
4279                 CHECK(preimages_conv_12->arr_len == 32);
4280                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4281                 preimages_constr.data[m] = preimages_conv_12_ref;
4282         }
4283         FREE(preimages);
4284         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4285         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4286         return (uint32_t)ret_conv;
4287 }
4288
4289 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4290         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4291         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4292         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4293         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4294         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4295         return ret_arr;
4296 }
4297
4298 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) {
4299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4301         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4302         LDKCommitmentTransaction commitment_tx_conv;
4303         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4304         commitment_tx_conv.is_owned = false;
4305         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4306         LDKCVec_PaymentPreimageZ preimages_constr;
4307         preimages_constr.datalen = preimages->arr_len;
4308         if (preimages_constr.datalen > 0)
4309                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4310         else
4311                 preimages_constr.data = NULL;
4312         int8_tArray* preimages_vals = (void*) preimages->elems;
4313         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4314                 int8_tArray preimages_conv_12 = preimages_vals[m];
4315                 LDKThirtyTwoBytes preimages_conv_12_ref;
4316                 CHECK(preimages_conv_12->arr_len == 32);
4317                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4318                 preimages_constr.data[m] = preimages_conv_12_ref;
4319         }
4320         FREE(preimages);
4321         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4322         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4323         return (uint32_t)ret_conv;
4324 }
4325
4326 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) {
4327         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4328         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4329         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4330         unsigned char secret_arr[32];
4331         CHECK(secret->arr_len == 32);
4332         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4333         unsigned char (*secret_ref)[32] = &secret_arr;
4334         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4335         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4336         return (uint32_t)ret_conv;
4337 }
4338
4339 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) {
4340         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4341         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4342         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4343         LDKHolderCommitmentTransaction commitment_tx_conv;
4344         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4345         commitment_tx_conv.is_owned = false;
4346         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4347         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4348         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4349         return (uint32_t)ret_conv;
4350 }
4351
4352 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) {
4353         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4355         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4356         LDKTransaction justice_tx_ref;
4357         justice_tx_ref.datalen = justice_tx->arr_len;
4358         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4359         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4360         justice_tx_ref.data_is_owned = true;
4361         unsigned char per_commitment_key_arr[32];
4362         CHECK(per_commitment_key->arr_len == 32);
4363         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4364         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4365         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4366         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4367         return (uint32_t)ret_conv;
4368 }
4369
4370 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) {
4371         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4373         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4374         LDKTransaction justice_tx_ref;
4375         justice_tx_ref.datalen = justice_tx->arr_len;
4376         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4377         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4378         justice_tx_ref.data_is_owned = true;
4379         unsigned char per_commitment_key_arr[32];
4380         CHECK(per_commitment_key->arr_len == 32);
4381         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4382         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4383         LDKHTLCOutputInCommitment htlc_conv;
4384         htlc_conv.inner = (void*)(htlc & (~1));
4385         htlc_conv.is_owned = false;
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4387         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4388         *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);
4389         return (uint32_t)ret_conv;
4390 }
4391
4392 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) {
4393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4395         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4396         LDKTransaction htlc_tx_ref;
4397         htlc_tx_ref.datalen = htlc_tx->arr_len;
4398         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4399         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4400         htlc_tx_ref.data_is_owned = true;
4401         LDKPublicKey per_commitment_point_ref;
4402         CHECK(per_commitment_point->arr_len == 33);
4403         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4404         LDKHTLCOutputInCommitment htlc_conv;
4405         htlc_conv.inner = (void*)(htlc & (~1));
4406         htlc_conv.is_owned = false;
4407         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4408         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4409         *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);
4410         return (uint32_t)ret_conv;
4411 }
4412
4413 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4414         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4415         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4416         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4417         LDKClosingTransaction closing_tx_conv;
4418         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4419         closing_tx_conv.is_owned = false;
4420         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4421         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4422         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4423         return (uint32_t)ret_conv;
4424 }
4425
4426 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4427         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4428         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4429         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4430         LDKUnsignedChannelAnnouncement msg_conv;
4431         msg_conv.inner = (void*)(msg & (~1));
4432         msg_conv.is_owned = false;
4433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4434         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4435         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4436         return (uint32_t)ret_conv;
4437 }
4438
4439 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
4440         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4441         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4442         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4443         LDKChannelTransactionParameters channel_parameters_conv;
4444         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4445         channel_parameters_conv.is_owned = false;
4446         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4447         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4448 }
4449
4450 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4451         if (this_arg->set_pubkeys != NULL)
4452                 this_arg->set_pubkeys(this_arg);
4453         return this_arg->pubkeys;
4454 }
4455 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4456         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4457         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4458         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4459         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4460         uint32_t ret_ref = 0;
4461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4464         ret_ref = (uintptr_t)ret_var.inner;
4465         if (ret_var.is_owned) {
4466                 ret_ref |= 1;
4467         }
4468         return ret_ref;
4469 }
4470
4471 typedef struct LDKSign_JCalls {
4472         atomic_size_t refcnt;
4473         uint32_t instance_ptr;
4474         LDKBaseSign_JCalls* BaseSign;
4475 } LDKSign_JCalls;
4476 static void LDKSign_JCalls_free(void* this_arg) {
4477         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4478         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4479                 FREE(j_calls);
4480         }
4481 }
4482 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4483         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4484         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 15);
4485         LDKCVec_u8Z ret_ref;
4486         ret_ref.datalen = ret->arr_len;
4487         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4488         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4489         return ret_ref;
4490 }
4491 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4492         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4493         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4494         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4495 }
4496 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4497         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4498         atomic_init(&calls->refcnt, 1);
4499         calls->instance_ptr = o;
4500
4501         LDKChannelPublicKeys pubkeys_conv;
4502         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4503         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4504         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4505
4506         LDKSign ret = {
4507                 .this_arg = (void*) calls,
4508                 .write = write_LDKSign_jcall,
4509                 .cloned = LDKSign_JCalls_cloned,
4510                 .free = LDKSign_JCalls_free,
4511                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4512         };
4513         calls->BaseSign = ret.BaseSign.this_arg;
4514         return ret;
4515 }
4516 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4517         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4518         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4519         return (long)res_ptr;
4520 }
4521 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4522         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4524         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4525         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4526         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4527         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4528         CVec_u8Z_free(ret_var);
4529         return ret_arr;
4530 }
4531
4532 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4533 CHECK(owner->result_ok);
4534         return Sign_clone(&*owner->contents.result);
4535 }
4536 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4537         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4538         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4539         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4540         return (uint32_t)ret_ret;
4541 }
4542
4543 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4544 CHECK(!owner->result_ok);
4545         return DecodeError_clone(&*owner->contents.err);
4546 }
4547 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4548         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4549         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4550         uint32_t ret_ref = 0;
4551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4554         ret_ref = (uintptr_t)ret_var.inner;
4555         if (ret_var.is_owned) {
4556                 ret_ref |= 1;
4557         }
4558         return ret_ref;
4559 }
4560
4561 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4562 CHECK(owner->result_ok);
4563         return *owner->contents.result;
4564 }
4565 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4566         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4567         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4568         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4569         return ret_arr;
4570 }
4571
4572 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4573 CHECK(!owner->result_ok);
4574         return *owner->contents.err;
4575 }
4576 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4577         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4578         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4579 }
4580
4581 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4582         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4583         for (size_t i = 0; i < ret.datalen; i++) {
4584                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4585         }
4586         return ret;
4587 }
4588 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4589 CHECK(owner->result_ok);
4590         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4591 }
4592 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4593         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4594         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4595         ptrArray ret_arr = NULL;
4596         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4597         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
4598         for (size_t m = 0; m < ret_var.datalen; m++) {
4599                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4600                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4601                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4602                 CVec_u8Z_free(ret_conv_12_var);
4603                 ret_arr_ptr[m] = ret_conv_12_arr;
4604         }
4605         
4606         FREE(ret_var.data);
4607         return ret_arr;
4608 }
4609
4610 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4611 CHECK(!owner->result_ok);
4612         return *owner->contents.err;
4613 }
4614 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4615         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4616         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4617 }
4618
4619 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4620 CHECK(owner->result_ok);
4621         return InMemorySigner_clone(&*owner->contents.result);
4622 }
4623 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4624         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4625         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4626         uint32_t ret_ref = 0;
4627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4630         ret_ref = (uintptr_t)ret_var.inner;
4631         if (ret_var.is_owned) {
4632                 ret_ref |= 1;
4633         }
4634         return ret_ref;
4635 }
4636
4637 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4638 CHECK(!owner->result_ok);
4639         return DecodeError_clone(&*owner->contents.err);
4640 }
4641 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4642         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4643         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4644         uint32_t ret_ref = 0;
4645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4648         ret_ref = (uintptr_t)ret_var.inner;
4649         if (ret_var.is_owned) {
4650                 ret_ref |= 1;
4651         }
4652         return ret_ref;
4653 }
4654
4655 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4656         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4657         for (size_t i = 0; i < ret.datalen; i++) {
4658                 ret.data[i] = TxOut_clone(&orig->data[i]);
4659         }
4660         return ret;
4661 }
4662 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4663 CHECK(owner->result_ok);
4664         return *owner->contents.result;
4665 }
4666 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4667         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4668         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4669         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4670         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4671         return ret_arr;
4672 }
4673
4674 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4675 CHECK(!owner->result_ok);
4676         return *owner->contents.err;
4677 }
4678 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4679         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4680         CResult_TransactionNoneZ_get_err(owner_conv);
4681 }
4682
4683 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4684         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4685         switch(obj->tag) {
4686                 case LDKCOption_u16Z_Some: return 0;
4687                 case LDKCOption_u16Z_None: return 1;
4688                 default: abort();
4689         }
4690 }
4691 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4692         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4693         assert(obj->tag == LDKCOption_u16Z_Some);
4694                         int16_t some_conv = obj->some;
4695         return some_conv;
4696 }
4697 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4698         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4699         switch(obj->tag) {
4700                 case LDKAPIError_APIMisuseError: return 0;
4701                 case LDKAPIError_FeeRateTooHigh: return 1;
4702                 case LDKAPIError_RouteError: return 2;
4703                 case LDKAPIError_ChannelUnavailable: return 3;
4704                 case LDKAPIError_MonitorUpdateFailed: return 4;
4705                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4706                 default: abort();
4707         }
4708 }
4709 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4710         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4711         assert(obj->tag == LDKAPIError_APIMisuseError);
4712                         LDKStr err_str = obj->api_misuse_error.err;
4713                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4714         return err_conv;
4715 }
4716 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4717         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4718         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4719                         LDKStr err_str = obj->fee_rate_too_high.err;
4720                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4721         return err_conv;
4722 }
4723 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4724         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4725         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4726                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4727         return feerate_conv;
4728 }
4729 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4730         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4731         assert(obj->tag == LDKAPIError_RouteError);
4732                         LDKStr err_str = obj->route_error.err;
4733                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4734         return err_conv;
4735 }
4736 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4737         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4738         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4739                         LDKStr err_str = obj->channel_unavailable.err;
4740                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4741         return err_conv;
4742 }
4743 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4744         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4745         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4746                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4747                         uint32_t script_ref = 0;
4748                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4749                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4750                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4751                         script_ref = (uintptr_t)script_var.inner & ~1;
4752         return script_ref;
4753 }
4754 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4755 CHECK(owner->result_ok);
4756         return *owner->contents.result;
4757 }
4758 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4759         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4760         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4761 }
4762
4763 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4764 CHECK(!owner->result_ok);
4765         return APIError_clone(&*owner->contents.err);
4766 }
4767 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4768         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4769         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4770         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4771         uint32_t ret_ref = (uintptr_t)ret_copy;
4772         return ret_ref;
4773 }
4774
4775 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4776         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4777         for (size_t i = 0; i < ret.datalen; i++) {
4778                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4779         }
4780         return ret;
4781 }
4782 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4783         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4784         for (size_t i = 0; i < ret.datalen; i++) {
4785                 ret.data[i] = APIError_clone(&orig->data[i]);
4786         }
4787         return ret;
4788 }
4789 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4790 CHECK(owner->result_ok);
4791         return ThirtyTwoBytes_clone(&*owner->contents.result);
4792 }
4793 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4794         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4795         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4796         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4797         return ret_arr;
4798 }
4799
4800 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4801 CHECK(!owner->result_ok);
4802         return APIError_clone(&*owner->contents.err);
4803 }
4804 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4805         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4806         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4807         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4808         uint32_t ret_ref = (uintptr_t)ret_copy;
4809         return ret_ref;
4810 }
4811
4812 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4813         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4814         switch(obj->tag) {
4815                 case LDKPaymentSendFailure_ParameterError: return 0;
4816                 case LDKPaymentSendFailure_PathParameterError: return 1;
4817                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4818                 case LDKPaymentSendFailure_PartialFailure: return 3;
4819                 default: abort();
4820         }
4821 }
4822 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4823         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4824         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4825                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4826         return parameter_error_ref;
4827 }
4828 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4829         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4830         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4831                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4832                         uint32_tArray path_parameter_error_arr = NULL;
4833                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4834                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
4835                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4836                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4837                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4838                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4839                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4840                         }
4841                         
4842         return path_parameter_error_arr;
4843 }
4844 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4845         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4846         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4847                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4848                         uint32_tArray all_failed_retry_safe_arr = NULL;
4849                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4850                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
4851                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4852                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4853                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4854                         }
4855                         
4856         return all_failed_retry_safe_arr;
4857 }
4858 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4859         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4860         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4861                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4862                         uint32_tArray results_arr = NULL;
4863                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4864                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
4865                         for (size_t w = 0; w < results_var.datalen; w++) {
4866                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4867                                 *results_conv_22_conv = results_var.data[w];
4868                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4869                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4870                         }
4871                         
4872         return results_arr;
4873 }
4874 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4875         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4876         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4877                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4878                         uint32_t failed_paths_retry_ref = 0;
4879                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4880                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4881                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4882                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4883                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4884                         }
4885         return failed_paths_retry_ref;
4886 }
4887 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4888         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4889         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4890                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4891                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4892         return payment_id_arr;
4893 }
4894 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4895 CHECK(owner->result_ok);
4896         return ThirtyTwoBytes_clone(&*owner->contents.result);
4897 }
4898 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4899         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4900         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4901         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4902         return ret_arr;
4903 }
4904
4905 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4906 CHECK(!owner->result_ok);
4907         return PaymentSendFailure_clone(&*owner->contents.err);
4908 }
4909 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4910         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4911         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4912         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4913         uint32_t ret_ref = (uintptr_t)ret_copy;
4914         return ret_ref;
4915 }
4916
4917 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4918 CHECK(owner->result_ok);
4919         return *owner->contents.result;
4920 }
4921 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4922         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4923         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4924 }
4925
4926 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4927 CHECK(!owner->result_ok);
4928         return PaymentSendFailure_clone(&*owner->contents.err);
4929 }
4930 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4931         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4932         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4933         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4934         uint32_t ret_ref = (uintptr_t)ret_copy;
4935         return ret_ref;
4936 }
4937
4938 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4939         return ThirtyTwoBytes_clone(&owner->a);
4940 }
4941 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4942         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4943         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4944         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4945         return ret_arr;
4946 }
4947
4948 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4949         return ThirtyTwoBytes_clone(&owner->b);
4950 }
4951 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4952         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4953         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4954         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4955         return ret_arr;
4956 }
4957
4958 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4959 CHECK(owner->result_ok);
4960         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4961 }
4962 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4963         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4964         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4965         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4966         return ((uint32_t)ret_conv);
4967 }
4968
4969 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4970 CHECK(!owner->result_ok);
4971         return PaymentSendFailure_clone(&*owner->contents.err);
4972 }
4973 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4974         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4975         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4976         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4977         uint32_t ret_ref = (uintptr_t)ret_copy;
4978         return ret_ref;
4979 }
4980
4981 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4982         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4983         for (size_t i = 0; i < ret.datalen; i++) {
4984                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4985         }
4986         return ret;
4987 }
4988 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4989         return ThirtyTwoBytes_clone(&owner->a);
4990 }
4991 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4992         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4993         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4994         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4995         return ret_arr;
4996 }
4997
4998 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4999         return ThirtyTwoBytes_clone(&owner->b);
5000 }
5001 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
5002         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5003         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5004         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
5005         return ret_arr;
5006 }
5007
5008 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5009 CHECK(owner->result_ok);
5010         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5011 }
5012 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
5013         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5014         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5015         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5016         return ((uint32_t)ret_conv);
5017 }
5018
5019 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5020 CHECK(!owner->result_ok);
5021         return *owner->contents.err;
5022 }
5023 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
5024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5025         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5026 }
5027
5028 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5029 CHECK(owner->result_ok);
5030         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5031 }
5032 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
5033         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5034         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5035         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5036         return ((uint32_t)ret_conv);
5037 }
5038
5039 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5040 CHECK(!owner->result_ok);
5041         return APIError_clone(&*owner->contents.err);
5042 }
5043 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
5044         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5045         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5046         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5047         uint32_t ret_ref = (uintptr_t)ret_copy;
5048         return ret_ref;
5049 }
5050
5051 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5052 CHECK(owner->result_ok);
5053         return ThirtyTwoBytes_clone(&*owner->contents.result);
5054 }
5055 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
5056         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5057         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5058         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
5059         return ret_arr;
5060 }
5061
5062 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5063 CHECK(!owner->result_ok);
5064         return *owner->contents.err;
5065 }
5066 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
5067         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5068         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5069 }
5070
5071 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5072 CHECK(owner->result_ok);
5073         return ThirtyTwoBytes_clone(&*owner->contents.result);
5074 }
5075 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
5076         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5077         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5078         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
5079         return ret_arr;
5080 }
5081
5082 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5083 CHECK(!owner->result_ok);
5084         return APIError_clone(&*owner->contents.err);
5085 }
5086 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
5087         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5088         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5089         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5090         uint32_t ret_ref = (uintptr_t)ret_copy;
5091         return ret_ref;
5092 }
5093
5094 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5095 CHECK(owner->result_ok);
5096         return ThirtyTwoBytes_clone(&*owner->contents.result);
5097 }
5098 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
5099         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5100         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5101         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
5102         return ret_arr;
5103 }
5104
5105 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5106 CHECK(!owner->result_ok);
5107         return APIError_clone(&*owner->contents.err);
5108 }
5109 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
5110         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5111         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5112         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5113         uint32_t ret_ref = (uintptr_t)ret_copy;
5114         return ret_ref;
5115 }
5116
5117 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5118 CHECK(owner->result_ok);
5119         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5120 }
5121 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
5122         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5123         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5124         uint32_t ret_ref = 0;
5125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5128         ret_ref = (uintptr_t)ret_var.inner;
5129         if (ret_var.is_owned) {
5130                 ret_ref |= 1;
5131         }
5132         return ret_ref;
5133 }
5134
5135 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5136 CHECK(!owner->result_ok);
5137         return DecodeError_clone(&*owner->contents.err);
5138 }
5139 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
5140         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5141         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5142         uint32_t ret_ref = 0;
5143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5146         ret_ref = (uintptr_t)ret_var.inner;
5147         if (ret_var.is_owned) {
5148                 ret_ref |= 1;
5149         }
5150         return ret_ref;
5151 }
5152
5153 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5154 CHECK(owner->result_ok);
5155         return ChannelCounterparty_clone(&*owner->contents.result);
5156 }
5157 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
5158         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5159         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5160         uint32_t ret_ref = 0;
5161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5164         ret_ref = (uintptr_t)ret_var.inner;
5165         if (ret_var.is_owned) {
5166                 ret_ref |= 1;
5167         }
5168         return ret_ref;
5169 }
5170
5171 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5172 CHECK(!owner->result_ok);
5173         return DecodeError_clone(&*owner->contents.err);
5174 }
5175 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
5176         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5177         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5178         uint32_t ret_ref = 0;
5179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5182         ret_ref = (uintptr_t)ret_var.inner;
5183         if (ret_var.is_owned) {
5184                 ret_ref |= 1;
5185         }
5186         return ret_ref;
5187 }
5188
5189 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5190 CHECK(owner->result_ok);
5191         return ChannelDetails_clone(&*owner->contents.result);
5192 }
5193 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
5194         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5195         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5196         uint32_t ret_ref = 0;
5197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5200         ret_ref = (uintptr_t)ret_var.inner;
5201         if (ret_var.is_owned) {
5202                 ret_ref |= 1;
5203         }
5204         return ret_ref;
5205 }
5206
5207 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5208 CHECK(!owner->result_ok);
5209         return DecodeError_clone(&*owner->contents.err);
5210 }
5211 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
5212         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5213         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5214         uint32_t ret_ref = 0;
5215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5218         ret_ref = (uintptr_t)ret_var.inner;
5219         if (ret_var.is_owned) {
5220                 ret_ref |= 1;
5221         }
5222         return ret_ref;
5223 }
5224
5225 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5226 CHECK(owner->result_ok);
5227         return PhantomRouteHints_clone(&*owner->contents.result);
5228 }
5229 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
5230         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5231         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5232         uint32_t ret_ref = 0;
5233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5236         ret_ref = (uintptr_t)ret_var.inner;
5237         if (ret_var.is_owned) {
5238                 ret_ref |= 1;
5239         }
5240         return ret_ref;
5241 }
5242
5243 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5244 CHECK(!owner->result_ok);
5245         return DecodeError_clone(&*owner->contents.err);
5246 }
5247 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
5248         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5249         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5250         uint32_t ret_ref = 0;
5251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5254         ret_ref = (uintptr_t)ret_var.inner;
5255         if (ret_var.is_owned) {
5256                 ret_ref |= 1;
5257         }
5258         return ret_ref;
5259 }
5260
5261 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5262         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5263         for (size_t i = 0; i < ret.datalen; i++) {
5264                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5265         }
5266         return ret;
5267 }
5268 typedef struct LDKWatch_JCalls {
5269         atomic_size_t refcnt;
5270         uint32_t instance_ptr;
5271 } LDKWatch_JCalls;
5272 static void LDKWatch_JCalls_free(void* this_arg) {
5273         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5274         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5275                 FREE(j_calls);
5276         }
5277 }
5278 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5279         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5280         LDKOutPoint funding_txo_var = funding_txo;
5281         uint32_t funding_txo_ref = 0;
5282         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5283         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5284         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5285         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5286         if (funding_txo_var.is_owned) {
5287                 funding_txo_ref |= 1;
5288         }
5289         LDKChannelMonitor monitor_var = monitor;
5290         uint32_t monitor_ref = 0;
5291         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5294         monitor_ref = (uintptr_t)monitor_var.inner;
5295         if (monitor_var.is_owned) {
5296                 monitor_ref |= 1;
5297         }
5298         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 16, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
5299         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5300         CHECK_ACCESS(ret_ptr);
5301         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5302         FREE((void*)ret);
5303         return ret_conv;
5304 }
5305 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5306         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5307         LDKOutPoint funding_txo_var = funding_txo;
5308         uint32_t funding_txo_ref = 0;
5309         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5310         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5311         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5312         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5313         if (funding_txo_var.is_owned) {
5314                 funding_txo_ref |= 1;
5315         }
5316         LDKChannelMonitorUpdate update_var = update;
5317         uint32_t update_ref = 0;
5318         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5319         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5320         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5321         update_ref = (uintptr_t)update_var.inner;
5322         if (update_var.is_owned) {
5323                 update_ref |= 1;
5324         }
5325         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 17, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
5326         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5327         CHECK_ACCESS(ret_ptr);
5328         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5329         FREE((void*)ret);
5330         return ret_conv;
5331 }
5332 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5333         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5334         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 18);
5335         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5336         ret_constr.datalen = ret->arr_len;
5337         if (ret_constr.datalen > 0)
5338                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5339         else
5340                 ret_constr.data = NULL;
5341         uint32_t* ret_vals = ret->elems;
5342         for (size_t x = 0; x < ret_constr.datalen; x++) {
5343                 uint32_t ret_conv_49 = ret_vals[x];
5344                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
5345                 CHECK_ACCESS(ret_conv_49_ptr);
5346                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5347                 FREE((void*)ret_conv_49);
5348                 ret_constr.data[x] = ret_conv_49_conv;
5349         }
5350         FREE(ret);
5351         return ret_constr;
5352 }
5353 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5354         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5355         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5356 }
5357 static inline LDKWatch LDKWatch_init (JSValue o) {
5358         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5359         atomic_init(&calls->refcnt, 1);
5360         calls->instance_ptr = o;
5361
5362         LDKWatch ret = {
5363                 .this_arg = (void*) calls,
5364                 .watch_channel = watch_channel_LDKWatch_jcall,
5365                 .update_channel = update_channel_LDKWatch_jcall,
5366                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5367                 .free = LDKWatch_JCalls_free,
5368         };
5369         return ret;
5370 }
5371 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5372         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5373         *res_ptr = LDKWatch_init(o);
5374         return (long)res_ptr;
5375 }
5376 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5377         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5378         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5379         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5380         LDKOutPoint funding_txo_conv;
5381         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5382         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5383         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5384         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5385         LDKChannelMonitor monitor_conv;
5386         monitor_conv.inner = (void*)(monitor & (~1));
5387         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5388         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5389         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5390         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5391         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5392         return (uint32_t)ret_conv;
5393 }
5394
5395 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5396         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5397         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5398         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5399         LDKOutPoint funding_txo_conv;
5400         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5401         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5402         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5403         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5404         LDKChannelMonitorUpdate update_conv;
5405         update_conv.inner = (void*)(update & (~1));
5406         update_conv.is_owned = (update & 1) || (update == 0);
5407         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5408         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5409         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5410         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5411         return (uint32_t)ret_conv;
5412 }
5413
5414 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5415         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5416         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5417         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5418         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5419         uint32_tArray ret_arr = NULL;
5420         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5421         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5422         for (size_t x = 0; x < ret_var.datalen; x++) {
5423                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
5424                 *ret_conv_49_conv = ret_var.data[x];
5425                 ret_arr_ptr[x] = ((uint32_t)ret_conv_49_conv);
5426         }
5427         
5428         FREE(ret_var.data);
5429         return ret_arr;
5430 }
5431
5432 typedef struct LDKBroadcasterInterface_JCalls {
5433         atomic_size_t refcnt;
5434         uint32_t instance_ptr;
5435 } LDKBroadcasterInterface_JCalls;
5436 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5437         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5438         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5439                 FREE(j_calls);
5440         }
5441 }
5442 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5443         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5444         LDKTransaction tx_var = tx;
5445         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5446         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5447         Transaction_free(tx_var);
5448         js_invoke_function_u_u(j_calls->instance_ptr, 19, (uint32_t)tx_arr);
5449 }
5450 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5451         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5452         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5453 }
5454 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5455         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5456         atomic_init(&calls->refcnt, 1);
5457         calls->instance_ptr = o;
5458
5459         LDKBroadcasterInterface ret = {
5460                 .this_arg = (void*) calls,
5461                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5462                 .free = LDKBroadcasterInterface_JCalls_free,
5463         };
5464         return ret;
5465 }
5466 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5467         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5468         *res_ptr = LDKBroadcasterInterface_init(o);
5469         return (long)res_ptr;
5470 }
5471 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5474         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5475         LDKTransaction tx_ref;
5476         tx_ref.datalen = tx->arr_len;
5477         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5478         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5479         tx_ref.data_is_owned = true;
5480         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5481 }
5482
5483 typedef struct LDKKeysInterface_JCalls {
5484         atomic_size_t refcnt;
5485         uint32_t instance_ptr;
5486 } LDKKeysInterface_JCalls;
5487 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5488         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5489         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5490                 FREE(j_calls);
5491         }
5492 }
5493 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5494         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5495         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5496         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 20, (uint32_t)recipient_conv);
5497         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5498         CHECK_ACCESS(ret_ptr);
5499         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5500         FREE((void*)ret);
5501         return ret_conv;
5502 }
5503 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5504         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5505         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 21);
5506         LDKCVec_u8Z ret_ref;
5507         ret_ref.datalen = ret->arr_len;
5508         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5509         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5510         return ret_ref;
5511 }
5512 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5513         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5514         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 22);
5515         LDKShutdownScript ret_conv;
5516         ret_conv.inner = (void*)(ret & (~1));
5517         ret_conv.is_owned = (ret & 1) || (ret == 0);
5518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5519         return ret_conv;
5520 }
5521 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5522         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5523         jboolean inbound_conv = inbound;
5524         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5525         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 23, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
5526         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5527         CHECK_ACCESS(ret_ptr);
5528         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5529         FREE((void*)ret);
5530         return ret_conv;
5531 }
5532 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5533         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5534         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 24);
5535         LDKThirtyTwoBytes ret_ref;
5536         CHECK(ret->arr_len == 32);
5537         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5538         return ret_ref;
5539 }
5540 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5541         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5542         LDKu8slice reader_var = reader;
5543         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5544         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5545         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 25, (uint32_t)reader_arr);
5546         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5547         CHECK_ACCESS(ret_ptr);
5548         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5549         FREE((void*)ret);
5550         return ret_conv;
5551 }
5552 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5553         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5554         LDKu8slice hrp_bytes_var = hrp_bytes;
5555         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5556         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5557         LDKCVec_u5Z invoice_data_var = invoice_data;
5558         ptrArray invoice_data_arr = NULL;
5559         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5560         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
5561         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5562                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5563                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5564         }
5565         
5566         FREE(invoice_data_var.data);
5567         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5568         uint32_t ret = js_invoke_function_u_uuu(j_calls->instance_ptr, 26, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, (uint32_t)receipient_conv);
5569         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5570         CHECK_ACCESS(ret_ptr);
5571         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5572         FREE((void*)ret);
5573         return ret_conv;
5574 }
5575 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5576         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5577         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 27);
5578         LDKThirtyTwoBytes ret_ref;
5579         CHECK(ret->arr_len == 32);
5580         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5581         return ret_ref;
5582 }
5583 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5584         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5586 }
5587 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5588         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5589         atomic_init(&calls->refcnt, 1);
5590         calls->instance_ptr = o;
5591
5592         LDKKeysInterface ret = {
5593                 .this_arg = (void*) calls,
5594                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5595                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5596                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5597                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5598                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5599                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5600                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5601                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5602                 .free = LDKKeysInterface_JCalls_free,
5603         };
5604         return ret;
5605 }
5606 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5607         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5608         *res_ptr = LDKKeysInterface_init(o);
5609         return (long)res_ptr;
5610 }
5611 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5612         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5613         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5614         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5615         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5616         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5617         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5618         return (uint32_t)ret_conv;
5619 }
5620
5621 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5625         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5626         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5627         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5628         CVec_u8Z_free(ret_var);
5629         return ret_arr;
5630 }
5631
5632 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5633         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5635         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5636         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5637         uint32_t ret_ref = 0;
5638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5641         ret_ref = (uintptr_t)ret_var.inner;
5642         if (ret_var.is_owned) {
5643                 ret_ref |= 1;
5644         }
5645         return ret_ref;
5646 }
5647
5648 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) {
5649         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5650         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5651         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5652         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5653         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5654         return (uint32_t)ret_ret;
5655 }
5656
5657 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5658         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5659         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5660         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5661         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5662         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5663         return ret_arr;
5664 }
5665
5666 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5669         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5670         LDKu8slice reader_ref;
5671         reader_ref.datalen = reader->arr_len;
5672         reader_ref.data = reader->elems;
5673         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5674         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5675         FREE(reader);
5676         return (uint32_t)ret_conv;
5677 }
5678
5679 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) {
5680         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5681         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5682         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5683         LDKu8slice hrp_bytes_ref;
5684         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5685         hrp_bytes_ref.data = hrp_bytes->elems;
5686         LDKCVec_u5Z invoice_data_constr;
5687         invoice_data_constr.datalen = invoice_data->arr_len;
5688         if (invoice_data_constr.datalen > 0)
5689                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5690         else
5691                 invoice_data_constr.data = NULL;
5692         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5693         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5694                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5695                 
5696                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5697         }
5698         FREE(invoice_data);
5699         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5700         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5701         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5702         FREE(hrp_bytes);
5703         return (uint32_t)ret_conv;
5704 }
5705
5706 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5707         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5708         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5709         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5710         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5711         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5712         return ret_arr;
5713 }
5714
5715 typedef struct LDKFeeEstimator_JCalls {
5716         atomic_size_t refcnt;
5717         uint32_t instance_ptr;
5718 } LDKFeeEstimator_JCalls;
5719 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5720         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5721         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5722                 FREE(j_calls);
5723         }
5724 }
5725 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5726         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5727         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5728         return js_invoke_function_u_u(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv);
5729 }
5730 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5731         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5732         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5733 }
5734 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5735         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5736         atomic_init(&calls->refcnt, 1);
5737         calls->instance_ptr = o;
5738
5739         LDKFeeEstimator ret = {
5740                 .this_arg = (void*) calls,
5741                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5742                 .free = LDKFeeEstimator_JCalls_free,
5743         };
5744         return ret;
5745 }
5746 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5747         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5748         *res_ptr = LDKFeeEstimator_init(o);
5749         return (long)res_ptr;
5750 }
5751 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) {
5752         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5753         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5754         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5755         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5756         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5757         return ret_conv;
5758 }
5759
5760 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5761         return ThirtyTwoBytes_clone(&owner->a);
5762 }
5763 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5764         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5765         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5766         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5767         return ret_arr;
5768 }
5769
5770 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5771         return &owner->b;
5772 }
5773 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5774         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5775         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5776         uint32_t ret_ref = 0;
5777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5780         ret_ref = (uintptr_t)ret_var.inner & ~1;
5781         return ret_ref;
5782 }
5783
5784 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5785 CHECK(owner->result_ok);
5786         return &*owner->contents.result;
5787 }
5788 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5789         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5790         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5791         return ret_ret;
5792 }
5793
5794 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5795 CHECK(!owner->result_ok);
5796         return DecodeError_clone(&*owner->contents.err);
5797 }
5798 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5799         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5800         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5801         uint32_t ret_ref = 0;
5802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5805         ret_ref = (uintptr_t)ret_var.inner;
5806         if (ret_var.is_owned) {
5807                 ret_ref |= 1;
5808         }
5809         return ret_ref;
5810 }
5811
5812 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5813 CHECK(owner->result_ok);
5814         return ChannelConfig_clone(&*owner->contents.result);
5815 }
5816 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5817         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5818         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5819         uint32_t ret_ref = 0;
5820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5823         ret_ref = (uintptr_t)ret_var.inner;
5824         if (ret_var.is_owned) {
5825                 ret_ref |= 1;
5826         }
5827         return ret_ref;
5828 }
5829
5830 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5831 CHECK(!owner->result_ok);
5832         return DecodeError_clone(&*owner->contents.err);
5833 }
5834 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5835         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5836         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5837         uint32_t ret_ref = 0;
5838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5841         ret_ref = (uintptr_t)ret_var.inner;
5842         if (ret_var.is_owned) {
5843                 ret_ref |= 1;
5844         }
5845         return ret_ref;
5846 }
5847
5848 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5849 CHECK(owner->result_ok);
5850         return OutPoint_clone(&*owner->contents.result);
5851 }
5852 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5853         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5854         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5855         uint32_t ret_ref = 0;
5856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5859         ret_ref = (uintptr_t)ret_var.inner;
5860         if (ret_var.is_owned) {
5861                 ret_ref |= 1;
5862         }
5863         return ret_ref;
5864 }
5865
5866 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5867 CHECK(!owner->result_ok);
5868         return DecodeError_clone(&*owner->contents.err);
5869 }
5870 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5871         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5872         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5873         uint32_t ret_ref = 0;
5874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5877         ret_ref = (uintptr_t)ret_var.inner;
5878         if (ret_var.is_owned) {
5879                 ret_ref |= 1;
5880         }
5881         return ret_ref;
5882 }
5883
5884 typedef struct LDKType_JCalls {
5885         atomic_size_t refcnt;
5886         uint32_t instance_ptr;
5887 } LDKType_JCalls;
5888 static void LDKType_JCalls_free(void* this_arg) {
5889         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5890         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5891                 FREE(j_calls);
5892         }
5893 }
5894 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5895         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5896         return js_invoke_function_u_(j_calls->instance_ptr, 29);
5897 }
5898 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5899         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5900         jstring ret = (jstring)js_invoke_function_u_(j_calls->instance_ptr, 30);
5901         LDKStr ret_conv = str_ref_to_owned_c(ret);
5902         return ret_conv;
5903 }
5904 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5905         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5906         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 31);
5907         LDKCVec_u8Z ret_ref;
5908         ret_ref.datalen = ret->arr_len;
5909         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5910         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5911         return ret_ref;
5912 }
5913 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5914         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5915         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5916 }
5917 static inline LDKType LDKType_init (JSValue o) {
5918         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5919         atomic_init(&calls->refcnt, 1);
5920         calls->instance_ptr = o;
5921
5922         LDKType ret = {
5923                 .this_arg = (void*) calls,
5924                 .type_id = type_id_LDKType_jcall,
5925                 .debug_str = debug_str_LDKType_jcall,
5926                 .write = write_LDKType_jcall,
5927                 .cloned = LDKType_JCalls_cloned,
5928                 .free = LDKType_JCalls_free,
5929         };
5930         return ret;
5931 }
5932 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5933         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5934         *res_ptr = LDKType_init(o);
5935         return (long)res_ptr;
5936 }
5937 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5938         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5939         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5940         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5941         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5942         return ret_conv;
5943 }
5944
5945 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5946         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5947         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5948         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5949         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5950         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5951         Str_free(ret_str);
5952         return ret_conv;
5953 }
5954
5955 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5956         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5957         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5958         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5959         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5960         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5961         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5962         CVec_u8Z_free(ret_var);
5963         return ret_arr;
5964 }
5965
5966 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5967         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5968         switch(obj->tag) {
5969                 case LDKCOption_TypeZ_Some: return 0;
5970                 case LDKCOption_TypeZ_None: return 1;
5971                 default: abort();
5972         }
5973 }
5974 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5975         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5976         assert(obj->tag == LDKCOption_TypeZ_Some);
5977                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5978                         *some_ret = Type_clone(&obj->some);
5979         return (uint32_t)some_ret;
5980 }
5981 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5982 CHECK(owner->result_ok);
5983         return COption_TypeZ_clone(&*owner->contents.result);
5984 }
5985 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5986         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5987         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5988         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5989         uint32_t ret_ref = (uintptr_t)ret_copy;
5990         return ret_ref;
5991 }
5992
5993 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5994 CHECK(!owner->result_ok);
5995         return DecodeError_clone(&*owner->contents.err);
5996 }
5997 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5998         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5999         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6000         uint32_t ret_ref = 0;
6001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6004         ret_ref = (uintptr_t)ret_var.inner;
6005         if (ret_var.is_owned) {
6006                 ret_ref |= 1;
6007         }
6008         return ret_ref;
6009 }
6010
6011 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
6012         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6013         switch(obj->tag) {
6014                 case LDKPaymentError_Invoice: return 0;
6015                 case LDKPaymentError_Routing: return 1;
6016                 case LDKPaymentError_Sending: return 2;
6017                 default: abort();
6018         }
6019 }
6020 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
6021         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6022         assert(obj->tag == LDKPaymentError_Invoice);
6023                         LDKStr invoice_str = obj->invoice;
6024                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
6025         return invoice_conv;
6026 }
6027 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
6028         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6029         assert(obj->tag == LDKPaymentError_Routing);
6030                         LDKLightningError routing_var = obj->routing;
6031                         uint32_t routing_ref = 0;
6032                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6033                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6034                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6035                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6036         return routing_ref;
6037 }
6038 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
6039         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6040         assert(obj->tag == LDKPaymentError_Sending);
6041                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6042         return sending_ref;
6043 }
6044 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6045 CHECK(owner->result_ok);
6046         return ThirtyTwoBytes_clone(&*owner->contents.result);
6047 }
6048 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
6049         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6051         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
6052         return ret_arr;
6053 }
6054
6055 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6056 CHECK(!owner->result_ok);
6057         return PaymentError_clone(&*owner->contents.err);
6058 }
6059 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
6060         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6061         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6062         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6063         uint32_t ret_ref = (uintptr_t)ret_copy;
6064         return ret_ref;
6065 }
6066
6067 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
6068         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6069         switch(obj->tag) {
6070                 case LDKParseError_Bech32Error: return 0;
6071                 case LDKParseError_ParseAmountError: return 1;
6072                 case LDKParseError_MalformedSignature: return 2;
6073                 case LDKParseError_BadPrefix: return 3;
6074                 case LDKParseError_UnknownCurrency: return 4;
6075                 case LDKParseError_UnknownSiPrefix: return 5;
6076                 case LDKParseError_MalformedHRP: return 6;
6077                 case LDKParseError_TooShortDataPart: return 7;
6078                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
6079                 case LDKParseError_DescriptionDecodeError: return 9;
6080                 case LDKParseError_PaddingError: return 10;
6081                 case LDKParseError_IntegerOverflowError: return 11;
6082                 case LDKParseError_InvalidSegWitProgramLength: return 12;
6083                 case LDKParseError_InvalidPubKeyHashLength: return 13;
6084                 case LDKParseError_InvalidScriptHashLength: return 14;
6085                 case LDKParseError_InvalidRecoveryId: return 15;
6086                 case LDKParseError_InvalidSliceLength: return 16;
6087                 case LDKParseError_Skip: return 17;
6088                 default: abort();
6089         }
6090 }
6091 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
6092         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6093         assert(obj->tag == LDKParseError_Bech32Error);
6094                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6095         return bech32_error_ref;
6096 }
6097 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
6098         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6099         assert(obj->tag == LDKParseError_ParseAmountError);
6100                         /*obj->parse_amount_error*/
6101         return 0;
6102 }
6103 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
6104         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6105         assert(obj->tag == LDKParseError_MalformedSignature);
6106                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
6107         return malformed_signature_conv;
6108 }
6109 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
6110         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6111         assert(obj->tag == LDKParseError_DescriptionDecodeError);
6112                         /*obj->description_decode_error*/
6113         return 0;
6114 }
6115 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
6116         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6117         assert(obj->tag == LDKParseError_InvalidSliceLength);
6118                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6119                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
6120         return invalid_slice_length_conv;
6121 }
6122 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6123 CHECK(owner->result_ok);
6124         return SiPrefix_clone(&*owner->contents.result);
6125 }
6126 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
6127         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6128         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6129         return ret_conv;
6130 }
6131
6132 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6133 CHECK(!owner->result_ok);
6134         return ParseError_clone(&*owner->contents.err);
6135 }
6136 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
6137         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6138         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6139         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
6140         uint32_t ret_ref = (uintptr_t)ret_copy;
6141         return ret_ref;
6142 }
6143
6144 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
6145         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6146         switch(obj->tag) {
6147                 case LDKParseOrSemanticError_ParseError: return 0;
6148                 case LDKParseOrSemanticError_SemanticError: return 1;
6149                 default: abort();
6150         }
6151 }
6152 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
6153         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6154         assert(obj->tag == LDKParseOrSemanticError_ParseError);
6155                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
6156         return parse_error_ref;
6157 }
6158 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
6159         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6160         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
6161                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
6162         return semantic_error_conv;
6163 }
6164 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6165 CHECK(owner->result_ok);
6166         return Invoice_clone(&*owner->contents.result);
6167 }
6168 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
6169         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6170         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
6171         uint32_t ret_ref = 0;
6172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6175         ret_ref = (uintptr_t)ret_var.inner;
6176         if (ret_var.is_owned) {
6177                 ret_ref |= 1;
6178         }
6179         return ret_ref;
6180 }
6181
6182 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6183 CHECK(!owner->result_ok);
6184         return ParseOrSemanticError_clone(&*owner->contents.err);
6185 }
6186 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
6187         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6188         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
6189         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
6190         uint32_t ret_ref = (uintptr_t)ret_copy;
6191         return ret_ref;
6192 }
6193
6194 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6195 CHECK(owner->result_ok);
6196         return SignedRawInvoice_clone(&*owner->contents.result);
6197 }
6198 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
6199         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6200         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
6201         uint32_t ret_ref = 0;
6202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6205         ret_ref = (uintptr_t)ret_var.inner;
6206         if (ret_var.is_owned) {
6207                 ret_ref |= 1;
6208         }
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6213 CHECK(!owner->result_ok);
6214         return ParseError_clone(&*owner->contents.err);
6215 }
6216 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
6217         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6218         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6219         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
6220         uint32_t ret_ref = (uintptr_t)ret_copy;
6221         return ret_ref;
6222 }
6223
6224 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6225         return RawInvoice_clone(&owner->a);
6226 }
6227 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
6228         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6229         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6230         uint32_t ret_ref = 0;
6231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6234         ret_ref = (uintptr_t)ret_var.inner;
6235         if (ret_var.is_owned) {
6236                 ret_ref |= 1;
6237         }
6238         return ret_ref;
6239 }
6240
6241 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6242         return ThirtyTwoBytes_clone(&owner->b);
6243 }
6244 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
6245         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6246         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6247         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
6248         return ret_arr;
6249 }
6250
6251 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6252         return InvoiceSignature_clone(&owner->c);
6253 }
6254 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
6255         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6256         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(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 LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6269 CHECK(owner->result_ok);
6270         return PayeePubKey_clone(&*owner->contents.result);
6271 }
6272 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
6273         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6274         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_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 enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6287 CHECK(!owner->result_ok);
6288         return *owner->contents.err;
6289 }
6290 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6291         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6292         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6293         return ret_conv;
6294 }
6295
6296 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6297         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6298         for (size_t i = 0; i < ret.datalen; i++) {
6299                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6300         }
6301         return ret;
6302 }
6303 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6304 CHECK(owner->result_ok);
6305         return PositiveTimestamp_clone(&*owner->contents.result);
6306 }
6307 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6308         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6309         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6310         uint32_t ret_ref = 0;
6311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6314         ret_ref = (uintptr_t)ret_var.inner;
6315         if (ret_var.is_owned) {
6316                 ret_ref |= 1;
6317         }
6318         return ret_ref;
6319 }
6320
6321 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6322 CHECK(!owner->result_ok);
6323         return CreationError_clone(&*owner->contents.err);
6324 }
6325 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6326         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6327         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6328         return ret_conv;
6329 }
6330
6331 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6332 CHECK(owner->result_ok);
6333         return *owner->contents.result;
6334 }
6335 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6336         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6337         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6338 }
6339
6340 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6341 CHECK(!owner->result_ok);
6342         return SemanticError_clone(&*owner->contents.err);
6343 }
6344 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6345         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6346         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6347         return ret_conv;
6348 }
6349
6350 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6351 CHECK(owner->result_ok);
6352         return Invoice_clone(&*owner->contents.result);
6353 }
6354 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6355         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6356         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6357         uint32_t ret_ref = 0;
6358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6361         ret_ref = (uintptr_t)ret_var.inner;
6362         if (ret_var.is_owned) {
6363                 ret_ref |= 1;
6364         }
6365         return ret_ref;
6366 }
6367
6368 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6369 CHECK(!owner->result_ok);
6370         return SemanticError_clone(&*owner->contents.err);
6371 }
6372 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6373         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6374         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6375         return ret_conv;
6376 }
6377
6378 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6379 CHECK(owner->result_ok);
6380         return Description_clone(&*owner->contents.result);
6381 }
6382 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6383         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6384         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6385         uint32_t ret_ref = 0;
6386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6389         ret_ref = (uintptr_t)ret_var.inner;
6390         if (ret_var.is_owned) {
6391                 ret_ref |= 1;
6392         }
6393         return ret_ref;
6394 }
6395
6396 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6397 CHECK(!owner->result_ok);
6398         return CreationError_clone(&*owner->contents.err);
6399 }
6400 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6401         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6402         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6403         return ret_conv;
6404 }
6405
6406 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6407 CHECK(owner->result_ok);
6408         return PrivateRoute_clone(&*owner->contents.result);
6409 }
6410 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6411         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6412         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6413         uint32_t ret_ref = 0;
6414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6417         ret_ref = (uintptr_t)ret_var.inner;
6418         if (ret_var.is_owned) {
6419                 ret_ref |= 1;
6420         }
6421         return ret_ref;
6422 }
6423
6424 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6425 CHECK(!owner->result_ok);
6426         return CreationError_clone(&*owner->contents.err);
6427 }
6428 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6429         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6430         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6431         return ret_conv;
6432 }
6433
6434 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6435 CHECK(owner->result_ok);
6436         return *owner->contents.result;
6437 }
6438 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6439         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6440         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6441         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6442         return ret_conv;
6443 }
6444
6445 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6446 CHECK(!owner->result_ok);
6447         return *owner->contents.err;
6448 }
6449 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6450         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6451         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6452         return ret_conv;
6453 }
6454
6455 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6456 CHECK(owner->result_ok);
6457         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6458 }
6459 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6460         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6461         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6462         uint32_t ret_ref = 0;
6463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6466         ret_ref = (uintptr_t)ret_var.inner;
6467         if (ret_var.is_owned) {
6468                 ret_ref |= 1;
6469         }
6470         return ret_ref;
6471 }
6472
6473 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6474 CHECK(!owner->result_ok);
6475         return DecodeError_clone(&*owner->contents.err);
6476 }
6477 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6478         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6479         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6480         uint32_t ret_ref = 0;
6481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6484         ret_ref = (uintptr_t)ret_var.inner;
6485         if (ret_var.is_owned) {
6486                 ret_ref |= 1;
6487         }
6488         return ret_ref;
6489 }
6490
6491 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6492         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6493         switch(obj->tag) {
6494                 case LDKCOption_MonitorEventZ_Some: return 0;
6495                 case LDKCOption_MonitorEventZ_None: return 1;
6496                 default: abort();
6497         }
6498 }
6499 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6500         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6501         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6502                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6503         return some_ref;
6504 }
6505 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6506 CHECK(owner->result_ok);
6507         return COption_MonitorEventZ_clone(&*owner->contents.result);
6508 }
6509 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6510         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6511         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6512         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6513         uint32_t ret_ref = (uintptr_t)ret_copy;
6514         return ret_ref;
6515 }
6516
6517 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6518 CHECK(!owner->result_ok);
6519         return DecodeError_clone(&*owner->contents.err);
6520 }
6521 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6522         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6523         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6524         uint32_t ret_ref = 0;
6525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6528         ret_ref = (uintptr_t)ret_var.inner;
6529         if (ret_var.is_owned) {
6530                 ret_ref |= 1;
6531         }
6532         return ret_ref;
6533 }
6534
6535 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6536 CHECK(owner->result_ok);
6537         return HTLCUpdate_clone(&*owner->contents.result);
6538 }
6539 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6540         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6541         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6542         uint32_t ret_ref = 0;
6543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6546         ret_ref = (uintptr_t)ret_var.inner;
6547         if (ret_var.is_owned) {
6548                 ret_ref |= 1;
6549         }
6550         return ret_ref;
6551 }
6552
6553 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6554 CHECK(!owner->result_ok);
6555         return DecodeError_clone(&*owner->contents.err);
6556 }
6557 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6558         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6559         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6560         uint32_t ret_ref = 0;
6561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6564         ret_ref = (uintptr_t)ret_var.inner;
6565         if (ret_var.is_owned) {
6566                 ret_ref |= 1;
6567         }
6568         return ret_ref;
6569 }
6570
6571 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6572         return OutPoint_clone(&owner->a);
6573 }
6574 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6575         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6576         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6577         uint32_t ret_ref = 0;
6578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6581         ret_ref = (uintptr_t)ret_var.inner;
6582         if (ret_var.is_owned) {
6583                 ret_ref |= 1;
6584         }
6585         return ret_ref;
6586 }
6587
6588 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6589         return CVec_u8Z_clone(&owner->b);
6590 }
6591 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6592         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6593         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6594         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6595         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6596         CVec_u8Z_free(ret_var);
6597         return ret_arr;
6598 }
6599
6600 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6601         return owner->a;
6602 }
6603 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6604         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6605         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6606         return ret_conv;
6607 }
6608
6609 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6610         return CVec_u8Z_clone(&owner->b);
6611 }
6612 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6613         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6614         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6615         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6616         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6617         CVec_u8Z_free(ret_var);
6618         return ret_arr;
6619 }
6620
6621 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6622         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6623         for (size_t i = 0; i < ret.datalen; i++) {
6624                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6625         }
6626         return ret;
6627 }
6628 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6629         return ThirtyTwoBytes_clone(&owner->a);
6630 }
6631 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6632         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6633         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6634         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6635         return ret_arr;
6636 }
6637
6638 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6639         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6640 }
6641 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6642         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6643         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6644         uint32_tArray ret_arr = NULL;
6645         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6646         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6647         for (size_t v = 0; v < ret_var.datalen; v++) {
6648                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6649                 *ret_conv_21_conv = ret_var.data[v];
6650                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6651         }
6652         
6653         FREE(ret_var.data);
6654         return ret_arr;
6655 }
6656
6657 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6658         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 };
6659         for (size_t i = 0; i < ret.datalen; i++) {
6660                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6661         }
6662         return ret;
6663 }
6664 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6665         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6666         for (size_t i = 0; i < ret.datalen; i++) {
6667                 ret.data[i] = Event_clone(&orig->data[i]);
6668         }
6669         return ret;
6670 }
6671 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6672         return owner->a;
6673 }
6674 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6675         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6676         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6677         return ret_conv;
6678 }
6679
6680 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6681         return TxOut_clone(&owner->b);
6682 }
6683 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6684         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6685         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6686         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6687         return (uint32_t)ret_ref;
6688 }
6689
6690 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6691         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6692         for (size_t i = 0; i < ret.datalen; i++) {
6693                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6694         }
6695         return ret;
6696 }
6697 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6698         return ThirtyTwoBytes_clone(&owner->a);
6699 }
6700 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6701         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6702         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6703         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6704         return ret_arr;
6705 }
6706
6707 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6708         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6709 }
6710 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6711         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6712         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6713         uint32_tArray ret_arr = NULL;
6714         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6715         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6716         for (size_t u = 0; u < ret_var.datalen; u++) {
6717                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6718                 *ret_conv_20_conv = ret_var.data[u];
6719                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6720         }
6721         
6722         FREE(ret_var.data);
6723         return ret_arr;
6724 }
6725
6726 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6727         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 };
6728         for (size_t i = 0; i < ret.datalen; i++) {
6729                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6730         }
6731         return ret;
6732 }
6733 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6734         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6735         switch(obj->tag) {
6736                 case LDKBalance_ClaimableOnChannelClose: return 0;
6737                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6738                 case LDKBalance_ContentiousClaimable: return 2;
6739                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6740                 default: abort();
6741         }
6742 }
6743 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6744         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6745         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6746                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6747         return claimable_amount_satoshis_conv;
6748 }
6749 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6750         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6751         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6752                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6753         return claimable_amount_satoshis_conv;
6754 }
6755 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6756         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6757         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6758                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6759         return confirmation_height_conv;
6760 }
6761 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6762         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6763         assert(obj->tag == LDKBalance_ContentiousClaimable);
6764                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6765         return claimable_amount_satoshis_conv;
6766 }
6767 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6768         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6769         assert(obj->tag == LDKBalance_ContentiousClaimable);
6770                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6771         return timeout_height_conv;
6772 }
6773 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6774         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6775         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6776                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6777         return claimable_amount_satoshis_conv;
6778 }
6779 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6780         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6781         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6782                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6783         return claimable_height_conv;
6784 }
6785 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6786         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6787         for (size_t i = 0; i < ret.datalen; i++) {
6788                 ret.data[i] = Balance_clone(&orig->data[i]);
6789         }
6790         return ret;
6791 }
6792 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6793         return ThirtyTwoBytes_clone(&owner->a);
6794 }
6795 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6796         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6797         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6798         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6799         return ret_arr;
6800 }
6801
6802 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6803         return ChannelMonitor_clone(&owner->b);
6804 }
6805 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6806         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6807         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6808         uint32_t ret_ref = 0;
6809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6812         ret_ref = (uintptr_t)ret_var.inner;
6813         if (ret_var.is_owned) {
6814                 ret_ref |= 1;
6815         }
6816         return ret_ref;
6817 }
6818
6819 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6820 CHECK(owner->result_ok);
6821         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6822 }
6823 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6824         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6825         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6826         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6827         return ((uint32_t)ret_conv);
6828 }
6829
6830 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6831 CHECK(!owner->result_ok);
6832         return DecodeError_clone(&*owner->contents.err);
6833 }
6834 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6835         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6836         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6837         uint32_t ret_ref = 0;
6838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6841         ret_ref = (uintptr_t)ret_var.inner;
6842         if (ret_var.is_owned) {
6843                 ret_ref |= 1;
6844         }
6845         return ret_ref;
6846 }
6847
6848 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6849         return owner->a;
6850 }
6851 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6852         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6853         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6854         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6855         return ret_arr;
6856 }
6857
6858 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6859         return Type_clone(&owner->b);
6860 }
6861 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6862         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6863         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6864         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6865         return (uint32_t)ret_ret;
6866 }
6867
6868 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6869         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6870         for (size_t i = 0; i < ret.datalen; i++) {
6871                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6872         }
6873         return ret;
6874 }
6875 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6876         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6877         switch(obj->tag) {
6878                 case LDKCOption_NetAddressZ_Some: return 0;
6879                 case LDKCOption_NetAddressZ_None: return 1;
6880                 default: abort();
6881         }
6882 }
6883 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6884         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6885         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6886                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6887         return some_ref;
6888 }
6889 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6890 CHECK(owner->result_ok);
6891         return CVec_u8Z_clone(&*owner->contents.result);
6892 }
6893 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6894         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6895         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6896         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6897         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6898         CVec_u8Z_free(ret_var);
6899         return ret_arr;
6900 }
6901
6902 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6903 CHECK(!owner->result_ok);
6904         return PeerHandleError_clone(&*owner->contents.err);
6905 }
6906 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6907         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6908         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6909         uint32_t ret_ref = 0;
6910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6913         ret_ref = (uintptr_t)ret_var.inner;
6914         if (ret_var.is_owned) {
6915                 ret_ref |= 1;
6916         }
6917         return ret_ref;
6918 }
6919
6920 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6921 CHECK(owner->result_ok);
6922         return *owner->contents.result;
6923 }
6924 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6925         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6926         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6927 }
6928
6929 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6930 CHECK(!owner->result_ok);
6931         return PeerHandleError_clone(&*owner->contents.err);
6932 }
6933 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6934         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6935         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(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 bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6948 CHECK(owner->result_ok);
6949         return *owner->contents.result;
6950 }
6951 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6952         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6953         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6954         return ret_conv;
6955 }
6956
6957 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6958 CHECK(!owner->result_ok);
6959         return PeerHandleError_clone(&*owner->contents.err);
6960 }
6961 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6962         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6963         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6964         uint32_t ret_ref = 0;
6965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6968         ret_ref = (uintptr_t)ret_var.inner;
6969         if (ret_var.is_owned) {
6970                 ret_ref |= 1;
6971         }
6972         return ret_ref;
6973 }
6974
6975 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6976 CHECK(owner->result_ok);
6977         return *owner->contents.result;
6978 }
6979 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6980         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6981         CResult_NoneErrorZ_get_ok(owner_conv);
6982 }
6983
6984 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6985 CHECK(!owner->result_ok);
6986         return *owner->contents.err;
6987 }
6988 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6989         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6990         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6991         return ret_conv;
6992 }
6993
6994 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6995 CHECK(owner->result_ok);
6996         return NetAddress_clone(&*owner->contents.result);
6997 }
6998 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6999         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7000         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
7001         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
7002         uint32_t ret_ref = (uintptr_t)ret_copy;
7003         return ret_ref;
7004 }
7005
7006 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
7007 CHECK(!owner->result_ok);
7008         return DecodeError_clone(&*owner->contents.err);
7009 }
7010 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
7011         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7012         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
7013         uint32_t ret_ref = 0;
7014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7017         ret_ref = (uintptr_t)ret_var.inner;
7018         if (ret_var.is_owned) {
7019                 ret_ref |= 1;
7020         }
7021         return ret_ref;
7022 }
7023
7024 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
7025         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
7026         for (size_t i = 0; i < ret.datalen; i++) {
7027                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
7028         }
7029         return ret;
7030 }
7031 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
7032         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
7033         for (size_t i = 0; i < ret.datalen; i++) {
7034                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
7035         }
7036         return ret;
7037 }
7038 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
7039         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
7040         for (size_t i = 0; i < ret.datalen; i++) {
7041                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
7042         }
7043         return ret;
7044 }
7045 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
7046         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
7047         for (size_t i = 0; i < ret.datalen; i++) {
7048                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
7049         }
7050         return ret;
7051 }
7052 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7053 CHECK(owner->result_ok);
7054         return AcceptChannel_clone(&*owner->contents.result);
7055 }
7056 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
7057         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7058         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
7059         uint32_t ret_ref = 0;
7060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7063         ret_ref = (uintptr_t)ret_var.inner;
7064         if (ret_var.is_owned) {
7065                 ret_ref |= 1;
7066         }
7067         return ret_ref;
7068 }
7069
7070 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7071 CHECK(!owner->result_ok);
7072         return DecodeError_clone(&*owner->contents.err);
7073 }
7074 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
7075         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7076         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
7077         uint32_t ret_ref = 0;
7078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7081         ret_ref = (uintptr_t)ret_var.inner;
7082         if (ret_var.is_owned) {
7083                 ret_ref |= 1;
7084         }
7085         return ret_ref;
7086 }
7087
7088 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7089 CHECK(owner->result_ok);
7090         return AnnouncementSignatures_clone(&*owner->contents.result);
7091 }
7092 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
7093         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7094         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
7095         uint32_t ret_ref = 0;
7096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7099         ret_ref = (uintptr_t)ret_var.inner;
7100         if (ret_var.is_owned) {
7101                 ret_ref |= 1;
7102         }
7103         return ret_ref;
7104 }
7105
7106 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7107 CHECK(!owner->result_ok);
7108         return DecodeError_clone(&*owner->contents.err);
7109 }
7110 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
7111         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7112         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
7113         uint32_t ret_ref = 0;
7114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7117         ret_ref = (uintptr_t)ret_var.inner;
7118         if (ret_var.is_owned) {
7119                 ret_ref |= 1;
7120         }
7121         return ret_ref;
7122 }
7123
7124 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7125 CHECK(owner->result_ok);
7126         return ChannelReestablish_clone(&*owner->contents.result);
7127 }
7128 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
7129         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7130         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
7131         uint32_t ret_ref = 0;
7132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7135         ret_ref = (uintptr_t)ret_var.inner;
7136         if (ret_var.is_owned) {
7137                 ret_ref |= 1;
7138         }
7139         return ret_ref;
7140 }
7141
7142 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7143 CHECK(!owner->result_ok);
7144         return DecodeError_clone(&*owner->contents.err);
7145 }
7146 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
7147         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7148         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
7149         uint32_t ret_ref = 0;
7150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7153         ret_ref = (uintptr_t)ret_var.inner;
7154         if (ret_var.is_owned) {
7155                 ret_ref |= 1;
7156         }
7157         return ret_ref;
7158 }
7159
7160 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7161 CHECK(owner->result_ok);
7162         return ClosingSigned_clone(&*owner->contents.result);
7163 }
7164 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7165         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7166         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
7167         uint32_t ret_ref = 0;
7168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7171         ret_ref = (uintptr_t)ret_var.inner;
7172         if (ret_var.is_owned) {
7173                 ret_ref |= 1;
7174         }
7175         return ret_ref;
7176 }
7177
7178 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7179 CHECK(!owner->result_ok);
7180         return DecodeError_clone(&*owner->contents.err);
7181 }
7182 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
7183         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7184         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
7185         uint32_t ret_ref = 0;
7186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7189         ret_ref = (uintptr_t)ret_var.inner;
7190         if (ret_var.is_owned) {
7191                 ret_ref |= 1;
7192         }
7193         return ret_ref;
7194 }
7195
7196 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7197 CHECK(owner->result_ok);
7198         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7199 }
7200 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
7201         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7202         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7203         uint32_t ret_ref = 0;
7204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7207         ret_ref = (uintptr_t)ret_var.inner;
7208         if (ret_var.is_owned) {
7209                 ret_ref |= 1;
7210         }
7211         return ret_ref;
7212 }
7213
7214 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7215 CHECK(!owner->result_ok);
7216         return DecodeError_clone(&*owner->contents.err);
7217 }
7218 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
7219         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7220         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7221         uint32_t ret_ref = 0;
7222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7225         ret_ref = (uintptr_t)ret_var.inner;
7226         if (ret_var.is_owned) {
7227                 ret_ref |= 1;
7228         }
7229         return ret_ref;
7230 }
7231
7232 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7233 CHECK(owner->result_ok);
7234         return CommitmentSigned_clone(&*owner->contents.result);
7235 }
7236 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
7237         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7238         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7239         uint32_t ret_ref = 0;
7240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7243         ret_ref = (uintptr_t)ret_var.inner;
7244         if (ret_var.is_owned) {
7245                 ret_ref |= 1;
7246         }
7247         return ret_ref;
7248 }
7249
7250 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7251 CHECK(!owner->result_ok);
7252         return DecodeError_clone(&*owner->contents.err);
7253 }
7254 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
7255         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7256         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7257         uint32_t ret_ref = 0;
7258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7261         ret_ref = (uintptr_t)ret_var.inner;
7262         if (ret_var.is_owned) {
7263                 ret_ref |= 1;
7264         }
7265         return ret_ref;
7266 }
7267
7268 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7269 CHECK(owner->result_ok);
7270         return FundingCreated_clone(&*owner->contents.result);
7271 }
7272 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
7273         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7274         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7275         uint32_t ret_ref = 0;
7276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7279         ret_ref = (uintptr_t)ret_var.inner;
7280         if (ret_var.is_owned) {
7281                 ret_ref |= 1;
7282         }
7283         return ret_ref;
7284 }
7285
7286 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7287 CHECK(!owner->result_ok);
7288         return DecodeError_clone(&*owner->contents.err);
7289 }
7290 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7291         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7292         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7293         uint32_t ret_ref = 0;
7294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7297         ret_ref = (uintptr_t)ret_var.inner;
7298         if (ret_var.is_owned) {
7299                 ret_ref |= 1;
7300         }
7301         return ret_ref;
7302 }
7303
7304 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7305 CHECK(owner->result_ok);
7306         return FundingSigned_clone(&*owner->contents.result);
7307 }
7308 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7309         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7310         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7311         uint32_t ret_ref = 0;
7312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7315         ret_ref = (uintptr_t)ret_var.inner;
7316         if (ret_var.is_owned) {
7317                 ret_ref |= 1;
7318         }
7319         return ret_ref;
7320 }
7321
7322 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7323 CHECK(!owner->result_ok);
7324         return DecodeError_clone(&*owner->contents.err);
7325 }
7326 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7327         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7328         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7329         uint32_t ret_ref = 0;
7330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7333         ret_ref = (uintptr_t)ret_var.inner;
7334         if (ret_var.is_owned) {
7335                 ret_ref |= 1;
7336         }
7337         return ret_ref;
7338 }
7339
7340 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7341 CHECK(owner->result_ok);
7342         return ChannelReady_clone(&*owner->contents.result);
7343 }
7344 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7345         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7346         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
7347         uint32_t ret_ref = 0;
7348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7351         ret_ref = (uintptr_t)ret_var.inner;
7352         if (ret_var.is_owned) {
7353                 ret_ref |= 1;
7354         }
7355         return ret_ref;
7356 }
7357
7358 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7359 CHECK(!owner->result_ok);
7360         return DecodeError_clone(&*owner->contents.err);
7361 }
7362 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7363         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7364         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
7365         uint32_t ret_ref = 0;
7366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7369         ret_ref = (uintptr_t)ret_var.inner;
7370         if (ret_var.is_owned) {
7371                 ret_ref |= 1;
7372         }
7373         return ret_ref;
7374 }
7375
7376 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7377 CHECK(owner->result_ok);
7378         return Init_clone(&*owner->contents.result);
7379 }
7380 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7381         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7382         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7383         uint32_t ret_ref = 0;
7384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7387         ret_ref = (uintptr_t)ret_var.inner;
7388         if (ret_var.is_owned) {
7389                 ret_ref |= 1;
7390         }
7391         return ret_ref;
7392 }
7393
7394 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7395 CHECK(!owner->result_ok);
7396         return DecodeError_clone(&*owner->contents.err);
7397 }
7398 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7399         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7400         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7401         uint32_t ret_ref = 0;
7402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7405         ret_ref = (uintptr_t)ret_var.inner;
7406         if (ret_var.is_owned) {
7407                 ret_ref |= 1;
7408         }
7409         return ret_ref;
7410 }
7411
7412 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7413 CHECK(owner->result_ok);
7414         return OpenChannel_clone(&*owner->contents.result);
7415 }
7416 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7417         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7418         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7419         uint32_t ret_ref = 0;
7420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7423         ret_ref = (uintptr_t)ret_var.inner;
7424         if (ret_var.is_owned) {
7425                 ret_ref |= 1;
7426         }
7427         return ret_ref;
7428 }
7429
7430 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7431 CHECK(!owner->result_ok);
7432         return DecodeError_clone(&*owner->contents.err);
7433 }
7434 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7435         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7436         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7437         uint32_t ret_ref = 0;
7438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7441         ret_ref = (uintptr_t)ret_var.inner;
7442         if (ret_var.is_owned) {
7443                 ret_ref |= 1;
7444         }
7445         return ret_ref;
7446 }
7447
7448 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7449 CHECK(owner->result_ok);
7450         return RevokeAndACK_clone(&*owner->contents.result);
7451 }
7452 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7453         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7454         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7455         uint32_t ret_ref = 0;
7456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7459         ret_ref = (uintptr_t)ret_var.inner;
7460         if (ret_var.is_owned) {
7461                 ret_ref |= 1;
7462         }
7463         return ret_ref;
7464 }
7465
7466 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7467 CHECK(!owner->result_ok);
7468         return DecodeError_clone(&*owner->contents.err);
7469 }
7470 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7471         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7472         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7473         uint32_t ret_ref = 0;
7474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7477         ret_ref = (uintptr_t)ret_var.inner;
7478         if (ret_var.is_owned) {
7479                 ret_ref |= 1;
7480         }
7481         return ret_ref;
7482 }
7483
7484 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7485 CHECK(owner->result_ok);
7486         return Shutdown_clone(&*owner->contents.result);
7487 }
7488 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7489         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7490         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7491         uint32_t ret_ref = 0;
7492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7495         ret_ref = (uintptr_t)ret_var.inner;
7496         if (ret_var.is_owned) {
7497                 ret_ref |= 1;
7498         }
7499         return ret_ref;
7500 }
7501
7502 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7503 CHECK(!owner->result_ok);
7504         return DecodeError_clone(&*owner->contents.err);
7505 }
7506 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7507         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7508         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7509         uint32_t ret_ref = 0;
7510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7513         ret_ref = (uintptr_t)ret_var.inner;
7514         if (ret_var.is_owned) {
7515                 ret_ref |= 1;
7516         }
7517         return ret_ref;
7518 }
7519
7520 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7521 CHECK(owner->result_ok);
7522         return UpdateFailHTLC_clone(&*owner->contents.result);
7523 }
7524 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7525         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7526         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7527         uint32_t ret_ref = 0;
7528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7531         ret_ref = (uintptr_t)ret_var.inner;
7532         if (ret_var.is_owned) {
7533                 ret_ref |= 1;
7534         }
7535         return ret_ref;
7536 }
7537
7538 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7539 CHECK(!owner->result_ok);
7540         return DecodeError_clone(&*owner->contents.err);
7541 }
7542 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7543         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7544         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7545         uint32_t ret_ref = 0;
7546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7549         ret_ref = (uintptr_t)ret_var.inner;
7550         if (ret_var.is_owned) {
7551                 ret_ref |= 1;
7552         }
7553         return ret_ref;
7554 }
7555
7556 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7557 CHECK(owner->result_ok);
7558         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7559 }
7560 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7561         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7562         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7563         uint32_t ret_ref = 0;
7564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7567         ret_ref = (uintptr_t)ret_var.inner;
7568         if (ret_var.is_owned) {
7569                 ret_ref |= 1;
7570         }
7571         return ret_ref;
7572 }
7573
7574 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7575 CHECK(!owner->result_ok);
7576         return DecodeError_clone(&*owner->contents.err);
7577 }
7578 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7579         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7580         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7581         uint32_t ret_ref = 0;
7582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7585         ret_ref = (uintptr_t)ret_var.inner;
7586         if (ret_var.is_owned) {
7587                 ret_ref |= 1;
7588         }
7589         return ret_ref;
7590 }
7591
7592 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7593 CHECK(owner->result_ok);
7594         return UpdateFee_clone(&*owner->contents.result);
7595 }
7596 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7597         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7598         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7599         uint32_t ret_ref = 0;
7600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7603         ret_ref = (uintptr_t)ret_var.inner;
7604         if (ret_var.is_owned) {
7605                 ret_ref |= 1;
7606         }
7607         return ret_ref;
7608 }
7609
7610 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7611 CHECK(!owner->result_ok);
7612         return DecodeError_clone(&*owner->contents.err);
7613 }
7614 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7615         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7616         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7617         uint32_t ret_ref = 0;
7618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7621         ret_ref = (uintptr_t)ret_var.inner;
7622         if (ret_var.is_owned) {
7623                 ret_ref |= 1;
7624         }
7625         return ret_ref;
7626 }
7627
7628 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7629 CHECK(owner->result_ok);
7630         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7631 }
7632 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7633         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7634         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7635         uint32_t ret_ref = 0;
7636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7639         ret_ref = (uintptr_t)ret_var.inner;
7640         if (ret_var.is_owned) {
7641                 ret_ref |= 1;
7642         }
7643         return ret_ref;
7644 }
7645
7646 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7647 CHECK(!owner->result_ok);
7648         return DecodeError_clone(&*owner->contents.err);
7649 }
7650 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7651         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7652         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7653         uint32_t ret_ref = 0;
7654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7657         ret_ref = (uintptr_t)ret_var.inner;
7658         if (ret_var.is_owned) {
7659                 ret_ref |= 1;
7660         }
7661         return ret_ref;
7662 }
7663
7664 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7665 CHECK(owner->result_ok);
7666         return UpdateAddHTLC_clone(&*owner->contents.result);
7667 }
7668 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7669         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7670         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7671         uint32_t ret_ref = 0;
7672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7675         ret_ref = (uintptr_t)ret_var.inner;
7676         if (ret_var.is_owned) {
7677                 ret_ref |= 1;
7678         }
7679         return ret_ref;
7680 }
7681
7682 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7683 CHECK(!owner->result_ok);
7684         return DecodeError_clone(&*owner->contents.err);
7685 }
7686 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7687         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7688         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7689         uint32_t ret_ref = 0;
7690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7693         ret_ref = (uintptr_t)ret_var.inner;
7694         if (ret_var.is_owned) {
7695                 ret_ref |= 1;
7696         }
7697         return ret_ref;
7698 }
7699
7700 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7701 CHECK(owner->result_ok);
7702         return Ping_clone(&*owner->contents.result);
7703 }
7704 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7705         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7706         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7707         uint32_t ret_ref = 0;
7708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7711         ret_ref = (uintptr_t)ret_var.inner;
7712         if (ret_var.is_owned) {
7713                 ret_ref |= 1;
7714         }
7715         return ret_ref;
7716 }
7717
7718 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7719 CHECK(!owner->result_ok);
7720         return DecodeError_clone(&*owner->contents.err);
7721 }
7722 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7723         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7724         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7725         uint32_t ret_ref = 0;
7726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7729         ret_ref = (uintptr_t)ret_var.inner;
7730         if (ret_var.is_owned) {
7731                 ret_ref |= 1;
7732         }
7733         return ret_ref;
7734 }
7735
7736 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7737 CHECK(owner->result_ok);
7738         return Pong_clone(&*owner->contents.result);
7739 }
7740 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7741         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7742         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7743         uint32_t ret_ref = 0;
7744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7747         ret_ref = (uintptr_t)ret_var.inner;
7748         if (ret_var.is_owned) {
7749                 ret_ref |= 1;
7750         }
7751         return ret_ref;
7752 }
7753
7754 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7755 CHECK(!owner->result_ok);
7756         return DecodeError_clone(&*owner->contents.err);
7757 }
7758 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7759         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7760         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7761         uint32_t ret_ref = 0;
7762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7765         ret_ref = (uintptr_t)ret_var.inner;
7766         if (ret_var.is_owned) {
7767                 ret_ref |= 1;
7768         }
7769         return ret_ref;
7770 }
7771
7772 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7773 CHECK(owner->result_ok);
7774         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7775 }
7776 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7777         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7778         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7779         uint32_t ret_ref = 0;
7780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7783         ret_ref = (uintptr_t)ret_var.inner;
7784         if (ret_var.is_owned) {
7785                 ret_ref |= 1;
7786         }
7787         return ret_ref;
7788 }
7789
7790 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7791 CHECK(!owner->result_ok);
7792         return DecodeError_clone(&*owner->contents.err);
7793 }
7794 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7795         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7796         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7797         uint32_t ret_ref = 0;
7798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7801         ret_ref = (uintptr_t)ret_var.inner;
7802         if (ret_var.is_owned) {
7803                 ret_ref |= 1;
7804         }
7805         return ret_ref;
7806 }
7807
7808 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7809 CHECK(owner->result_ok);
7810         return ChannelAnnouncement_clone(&*owner->contents.result);
7811 }
7812 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7813         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7814         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7815         uint32_t ret_ref = 0;
7816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7819         ret_ref = (uintptr_t)ret_var.inner;
7820         if (ret_var.is_owned) {
7821                 ret_ref |= 1;
7822         }
7823         return ret_ref;
7824 }
7825
7826 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7827 CHECK(!owner->result_ok);
7828         return DecodeError_clone(&*owner->contents.err);
7829 }
7830 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7831         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7832         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7833         uint32_t ret_ref = 0;
7834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7837         ret_ref = (uintptr_t)ret_var.inner;
7838         if (ret_var.is_owned) {
7839                 ret_ref |= 1;
7840         }
7841         return ret_ref;
7842 }
7843
7844 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7845 CHECK(owner->result_ok);
7846         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7847 }
7848 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7849         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7850         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7851         uint32_t ret_ref = 0;
7852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7855         ret_ref = (uintptr_t)ret_var.inner;
7856         if (ret_var.is_owned) {
7857                 ret_ref |= 1;
7858         }
7859         return ret_ref;
7860 }
7861
7862 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7863 CHECK(!owner->result_ok);
7864         return DecodeError_clone(&*owner->contents.err);
7865 }
7866 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7867         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7868         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7869         uint32_t ret_ref = 0;
7870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7873         ret_ref = (uintptr_t)ret_var.inner;
7874         if (ret_var.is_owned) {
7875                 ret_ref |= 1;
7876         }
7877         return ret_ref;
7878 }
7879
7880 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7881 CHECK(owner->result_ok);
7882         return ChannelUpdate_clone(&*owner->contents.result);
7883 }
7884 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7885         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7886         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7887         uint32_t ret_ref = 0;
7888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7891         ret_ref = (uintptr_t)ret_var.inner;
7892         if (ret_var.is_owned) {
7893                 ret_ref |= 1;
7894         }
7895         return ret_ref;
7896 }
7897
7898 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7899 CHECK(!owner->result_ok);
7900         return DecodeError_clone(&*owner->contents.err);
7901 }
7902 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7903         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7904         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7905         uint32_t ret_ref = 0;
7906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7909         ret_ref = (uintptr_t)ret_var.inner;
7910         if (ret_var.is_owned) {
7911                 ret_ref |= 1;
7912         }
7913         return ret_ref;
7914 }
7915
7916 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7917 CHECK(owner->result_ok);
7918         return ErrorMessage_clone(&*owner->contents.result);
7919 }
7920 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7921         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7922         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7923         uint32_t ret_ref = 0;
7924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7927         ret_ref = (uintptr_t)ret_var.inner;
7928         if (ret_var.is_owned) {
7929                 ret_ref |= 1;
7930         }
7931         return ret_ref;
7932 }
7933
7934 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7935 CHECK(!owner->result_ok);
7936         return DecodeError_clone(&*owner->contents.err);
7937 }
7938 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7939         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7940         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7941         uint32_t ret_ref = 0;
7942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7945         ret_ref = (uintptr_t)ret_var.inner;
7946         if (ret_var.is_owned) {
7947                 ret_ref |= 1;
7948         }
7949         return ret_ref;
7950 }
7951
7952 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7953 CHECK(owner->result_ok);
7954         return WarningMessage_clone(&*owner->contents.result);
7955 }
7956 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7957         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7958         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7959         uint32_t ret_ref = 0;
7960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7963         ret_ref = (uintptr_t)ret_var.inner;
7964         if (ret_var.is_owned) {
7965                 ret_ref |= 1;
7966         }
7967         return ret_ref;
7968 }
7969
7970 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7971 CHECK(!owner->result_ok);
7972         return DecodeError_clone(&*owner->contents.err);
7973 }
7974 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7975         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7976         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7977         uint32_t ret_ref = 0;
7978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7981         ret_ref = (uintptr_t)ret_var.inner;
7982         if (ret_var.is_owned) {
7983                 ret_ref |= 1;
7984         }
7985         return ret_ref;
7986 }
7987
7988 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7989 CHECK(owner->result_ok);
7990         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7991 }
7992 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7993         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7994         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7995         uint32_t ret_ref = 0;
7996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7999         ret_ref = (uintptr_t)ret_var.inner;
8000         if (ret_var.is_owned) {
8001                 ret_ref |= 1;
8002         }
8003         return ret_ref;
8004 }
8005
8006 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8007 CHECK(!owner->result_ok);
8008         return DecodeError_clone(&*owner->contents.err);
8009 }
8010 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8011         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
8012         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8013         uint32_t ret_ref = 0;
8014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8017         ret_ref = (uintptr_t)ret_var.inner;
8018         if (ret_var.is_owned) {
8019                 ret_ref |= 1;
8020         }
8021         return ret_ref;
8022 }
8023
8024 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8025 CHECK(owner->result_ok);
8026         return NodeAnnouncement_clone(&*owner->contents.result);
8027 }
8028 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
8029         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8030         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8031         uint32_t ret_ref = 0;
8032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8035         ret_ref = (uintptr_t)ret_var.inner;
8036         if (ret_var.is_owned) {
8037                 ret_ref |= 1;
8038         }
8039         return ret_ref;
8040 }
8041
8042 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8043 CHECK(!owner->result_ok);
8044         return DecodeError_clone(&*owner->contents.err);
8045 }
8046 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8047         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8048         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8049         uint32_t ret_ref = 0;
8050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8053         ret_ref = (uintptr_t)ret_var.inner;
8054         if (ret_var.is_owned) {
8055                 ret_ref |= 1;
8056         }
8057         return ret_ref;
8058 }
8059
8060 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8061 CHECK(owner->result_ok);
8062         return QueryShortChannelIds_clone(&*owner->contents.result);
8063 }
8064 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
8065         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8066         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
8067         uint32_t ret_ref = 0;
8068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8071         ret_ref = (uintptr_t)ret_var.inner;
8072         if (ret_var.is_owned) {
8073                 ret_ref |= 1;
8074         }
8075         return ret_ref;
8076 }
8077
8078 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8079 CHECK(!owner->result_ok);
8080         return DecodeError_clone(&*owner->contents.err);
8081 }
8082 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
8083         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8084         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
8085         uint32_t ret_ref = 0;
8086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8089         ret_ref = (uintptr_t)ret_var.inner;
8090         if (ret_var.is_owned) {
8091                 ret_ref |= 1;
8092         }
8093         return ret_ref;
8094 }
8095
8096 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8097 CHECK(owner->result_ok);
8098         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
8099 }
8100 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
8101         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8102         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
8103         uint32_t ret_ref = 0;
8104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8107         ret_ref = (uintptr_t)ret_var.inner;
8108         if (ret_var.is_owned) {
8109                 ret_ref |= 1;
8110         }
8111         return ret_ref;
8112 }
8113
8114 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8115 CHECK(!owner->result_ok);
8116         return DecodeError_clone(&*owner->contents.err);
8117 }
8118 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
8119         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8120         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
8121         uint32_t ret_ref = 0;
8122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8125         ret_ref = (uintptr_t)ret_var.inner;
8126         if (ret_var.is_owned) {
8127                 ret_ref |= 1;
8128         }
8129         return ret_ref;
8130 }
8131
8132 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8133 CHECK(owner->result_ok);
8134         return QueryChannelRange_clone(&*owner->contents.result);
8135 }
8136 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8137         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8138         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
8139         uint32_t ret_ref = 0;
8140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8143         ret_ref = (uintptr_t)ret_var.inner;
8144         if (ret_var.is_owned) {
8145                 ret_ref |= 1;
8146         }
8147         return ret_ref;
8148 }
8149
8150 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8151 CHECK(!owner->result_ok);
8152         return DecodeError_clone(&*owner->contents.err);
8153 }
8154 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8155         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8156         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
8157         uint32_t ret_ref = 0;
8158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8161         ret_ref = (uintptr_t)ret_var.inner;
8162         if (ret_var.is_owned) {
8163                 ret_ref |= 1;
8164         }
8165         return ret_ref;
8166 }
8167
8168 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8169 CHECK(owner->result_ok);
8170         return ReplyChannelRange_clone(&*owner->contents.result);
8171 }
8172 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8173         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8174         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
8175         uint32_t ret_ref = 0;
8176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8179         ret_ref = (uintptr_t)ret_var.inner;
8180         if (ret_var.is_owned) {
8181                 ret_ref |= 1;
8182         }
8183         return ret_ref;
8184 }
8185
8186 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8187 CHECK(!owner->result_ok);
8188         return DecodeError_clone(&*owner->contents.err);
8189 }
8190 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8191         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8192         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
8193         uint32_t ret_ref = 0;
8194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8197         ret_ref = (uintptr_t)ret_var.inner;
8198         if (ret_var.is_owned) {
8199                 ret_ref |= 1;
8200         }
8201         return ret_ref;
8202 }
8203
8204 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8205 CHECK(owner->result_ok);
8206         return GossipTimestampFilter_clone(&*owner->contents.result);
8207 }
8208 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
8209         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8210         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8211         uint32_t ret_ref = 0;
8212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8215         ret_ref = (uintptr_t)ret_var.inner;
8216         if (ret_var.is_owned) {
8217                 ret_ref |= 1;
8218         }
8219         return ret_ref;
8220 }
8221
8222 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8223 CHECK(!owner->result_ok);
8224         return DecodeError_clone(&*owner->contents.err);
8225 }
8226 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
8227         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8228         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8229         uint32_t ret_ref = 0;
8230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8233         ret_ref = (uintptr_t)ret_var.inner;
8234         if (ret_var.is_owned) {
8235                 ret_ref |= 1;
8236         }
8237         return ret_ref;
8238 }
8239
8240 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
8241         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8242         switch(obj->tag) {
8243                 case LDKSignOrCreationError_SignError: return 0;
8244                 case LDKSignOrCreationError_CreationError: return 1;
8245                 default: abort();
8246         }
8247 }
8248 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
8249         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8250         assert(obj->tag == LDKSignOrCreationError_CreationError);
8251                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
8252         return creation_error_conv;
8253 }
8254 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8255 CHECK(owner->result_ok);
8256         return Invoice_clone(&*owner->contents.result);
8257 }
8258 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
8259         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8260         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8261         uint32_t ret_ref = 0;
8262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8265         ret_ref = (uintptr_t)ret_var.inner;
8266         if (ret_var.is_owned) {
8267                 ret_ref |= 1;
8268         }
8269         return ret_ref;
8270 }
8271
8272 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8273 CHECK(!owner->result_ok);
8274         return SignOrCreationError_clone(&*owner->contents.err);
8275 }
8276 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
8277         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8278         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8279         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8280         uint32_t ret_ref = (uintptr_t)ret_copy;
8281         return ret_ref;
8282 }
8283
8284 typedef struct LDKFilter_JCalls {
8285         atomic_size_t refcnt;
8286         uint32_t instance_ptr;
8287 } LDKFilter_JCalls;
8288 static void LDKFilter_JCalls_free(void* this_arg) {
8289         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8290         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8291                 FREE(j_calls);
8292         }
8293 }
8294 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8295         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8296         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8297         memcpy(txid_arr->elems, *txid, 32);
8298         LDKu8slice script_pubkey_var = script_pubkey;
8299         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8300         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8301         js_invoke_function_u_uu(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
8302 }
8303 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8304         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8305         LDKWatchedOutput output_var = output;
8306         uint32_t output_ref = 0;
8307         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8308         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8309         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8310         output_ref = (uintptr_t)output_var.inner;
8311         if (output_var.is_owned) {
8312                 output_ref |= 1;
8313         }
8314         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 33, (uint32_t)output_ref);
8315         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8316         CHECK_ACCESS(ret_ptr);
8317         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8318         FREE((void*)ret);
8319         return ret_conv;
8320 }
8321 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8322         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8323         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8324 }
8325 static inline LDKFilter LDKFilter_init (JSValue o) {
8326         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8327         atomic_init(&calls->refcnt, 1);
8328         calls->instance_ptr = o;
8329
8330         LDKFilter ret = {
8331                 .this_arg = (void*) calls,
8332                 .register_tx = register_tx_LDKFilter_jcall,
8333                 .register_output = register_output_LDKFilter_jcall,
8334                 .free = LDKFilter_JCalls_free,
8335         };
8336         return ret;
8337 }
8338 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8339         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8340         *res_ptr = LDKFilter_init(o);
8341         return (long)res_ptr;
8342 }
8343 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8346         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8347         unsigned char txid_arr[32];
8348         CHECK(txid->arr_len == 32);
8349         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8350         unsigned char (*txid_ref)[32] = &txid_arr;
8351         LDKu8slice script_pubkey_ref;
8352         script_pubkey_ref.datalen = script_pubkey->arr_len;
8353         script_pubkey_ref.data = script_pubkey->elems;
8354         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8355         FREE(script_pubkey);
8356 }
8357
8358 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8359         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8360         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8361         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8362         LDKWatchedOutput output_conv;
8363         output_conv.inner = (void*)(output & (~1));
8364         output_conv.is_owned = (output & 1) || (output == 0);
8365         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8366         output_conv = WatchedOutput_clone(&output_conv);
8367         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8368         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8369         uint32_t ret_ref = (uintptr_t)ret_copy;
8370         return ret_ref;
8371 }
8372
8373 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8374         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8375         switch(obj->tag) {
8376                 case LDKCOption_FilterZ_Some: return 0;
8377                 case LDKCOption_FilterZ_None: return 1;
8378                 default: abort();
8379         }
8380 }
8381 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8382         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8383         assert(obj->tag == LDKCOption_FilterZ_Some);
8384                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8385                         *some_ret = obj->some;
8386                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8387                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8388                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8389                                 LDKFilter_JCalls_cloned(&(*some_ret));
8390                         }
8391         return (uint32_t)some_ret;
8392 }
8393 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8394 CHECK(owner->result_ok);
8395         return &*owner->contents.result;
8396 }
8397 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8398         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8399         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8400         uint32_t ret_ref = 0;
8401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8404         ret_ref = (uintptr_t)ret_var.inner & ~1;
8405         return ret_ref;
8406 }
8407
8408 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8409 CHECK(!owner->result_ok);
8410         return *owner->contents.err;
8411 }
8412 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8413         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8414         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8415 }
8416
8417 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8418         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8419         for (size_t i = 0; i < ret.datalen; i++) {
8420                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8421         }
8422         return ret;
8423 }
8424 typedef struct LDKMessageSendEventsProvider_JCalls {
8425         atomic_size_t refcnt;
8426         uint32_t instance_ptr;
8427 } LDKMessageSendEventsProvider_JCalls;
8428 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8429         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8430         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8431                 FREE(j_calls);
8432         }
8433 }
8434 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8435         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8436         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 34);
8437         LDKCVec_MessageSendEventZ ret_constr;
8438         ret_constr.datalen = ret->arr_len;
8439         if (ret_constr.datalen > 0)
8440                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8441         else
8442                 ret_constr.data = NULL;
8443         uint32_t* ret_vals = ret->elems;
8444         for (size_t s = 0; s < ret_constr.datalen; s++) {
8445                 uint32_t ret_conv_18 = ret_vals[s];
8446                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8447                 CHECK_ACCESS(ret_conv_18_ptr);
8448                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8449                 FREE((void*)ret_conv_18);
8450                 ret_constr.data[s] = ret_conv_18_conv;
8451         }
8452         FREE(ret);
8453         return ret_constr;
8454 }
8455 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8456         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8457         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8458 }
8459 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8460         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8461         atomic_init(&calls->refcnt, 1);
8462         calls->instance_ptr = o;
8463
8464         LDKMessageSendEventsProvider ret = {
8465                 .this_arg = (void*) calls,
8466                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8467                 .free = LDKMessageSendEventsProvider_JCalls_free,
8468         };
8469         return ret;
8470 }
8471 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8472         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8473         *res_ptr = LDKMessageSendEventsProvider_init(o);
8474         return (long)res_ptr;
8475 }
8476 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) {
8477         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8478         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8479         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8480         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8481         uint32_tArray ret_arr = NULL;
8482         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8483         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8484         for (size_t s = 0; s < ret_var.datalen; s++) {
8485                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8486                 *ret_conv_18_copy = ret_var.data[s];
8487                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8488                 ret_arr_ptr[s] = ret_conv_18_ref;
8489         }
8490         
8491         FREE(ret_var.data);
8492         return ret_arr;
8493 }
8494
8495 typedef struct LDKEventHandler_JCalls {
8496         atomic_size_t refcnt;
8497         uint32_t instance_ptr;
8498 } LDKEventHandler_JCalls;
8499 static void LDKEventHandler_JCalls_free(void* this_arg) {
8500         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8501         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8502                 FREE(j_calls);
8503         }
8504 }
8505 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8506         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8507         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8508         *ret_event = Event_clone(event);
8509         js_invoke_function_u_u(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8510 }
8511 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8512         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8514 }
8515 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8516         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8517         atomic_init(&calls->refcnt, 1);
8518         calls->instance_ptr = o;
8519
8520         LDKEventHandler ret = {
8521                 .this_arg = (void*) calls,
8522                 .handle_event = handle_event_LDKEventHandler_jcall,
8523                 .free = LDKEventHandler_JCalls_free,
8524         };
8525         return ret;
8526 }
8527 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8528         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8529         *res_ptr = LDKEventHandler_init(o);
8530         return (long)res_ptr;
8531 }
8532 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8533         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8534         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8535         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8536         LDKEvent* event_conv = (LDKEvent*)event;
8537         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8538 }
8539
8540 typedef struct LDKEventsProvider_JCalls {
8541         atomic_size_t refcnt;
8542         uint32_t instance_ptr;
8543 } LDKEventsProvider_JCalls;
8544 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8545         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8546         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8547                 FREE(j_calls);
8548         }
8549 }
8550 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8551         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8552         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8553         *handler_ret = handler;
8554         js_invoke_function_u_u(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8555 }
8556 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8557         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8558         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8559 }
8560 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8561         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8562         atomic_init(&calls->refcnt, 1);
8563         calls->instance_ptr = o;
8564
8565         LDKEventsProvider ret = {
8566                 .this_arg = (void*) calls,
8567                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8568                 .free = LDKEventsProvider_JCalls_free,
8569         };
8570         return ret;
8571 }
8572 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8573         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8574         *res_ptr = LDKEventsProvider_init(o);
8575         return (long)res_ptr;
8576 }
8577 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8578         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8580         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8581         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8582         CHECK_ACCESS(handler_ptr);
8583         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8584         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8586                 LDKEventHandler_JCalls_cloned(&handler_conv);
8587         }
8588         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8589 }
8590
8591 typedef struct LDKScore_JCalls {
8592         atomic_size_t refcnt;
8593         uint32_t instance_ptr;
8594 } LDKScore_JCalls;
8595 static void LDKScore_JCalls_free(void* this_arg) {
8596         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8597         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8598                 FREE(j_calls);
8599         }
8600 }
8601 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8602         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8603         int64_t short_channel_id_conv = short_channel_id;
8604         LDKNodeId source_var = *source;
8605         uint32_t source_ref = 0;
8606         source_var = NodeId_clone(&source_var);
8607         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8608         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8609         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8610         source_ref = (uintptr_t)source_var.inner;
8611         if (source_var.is_owned) {
8612                 source_ref |= 1;
8613         }
8614         LDKNodeId target_var = *target;
8615         uint32_t target_ref = 0;
8616         target_var = NodeId_clone(&target_var);
8617         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8618         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8619         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8620         target_ref = (uintptr_t)target_var.inner;
8621         if (target_var.is_owned) {
8622                 target_ref |= 1;
8623         }
8624         LDKChannelUsage usage_var = usage;
8625         uint32_t usage_ref = 0;
8626         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8627         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8628         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8629         usage_ref = (uintptr_t)usage_var.inner;
8630         if (usage_var.is_owned) {
8631                 usage_ref |= 1;
8632         }
8633         return js_invoke_function_b_uuuu(j_calls->instance_ptr, 37, (uint32_t)short_channel_id_conv, (uint32_t)source_ref, (uint32_t)target_ref, (uint32_t)usage_ref);
8634 }
8635 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8636         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8637         LDKCVec_RouteHopZ path_var = path;
8638         uint32_tArray path_arr = NULL;
8639         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8640         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8641         for (size_t k = 0; k < path_var.datalen; k++) {
8642                 LDKRouteHop path_conv_10_var = path_var.data[k];
8643                 uint32_t path_conv_10_ref = 0;
8644                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8645                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8647                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8648                 if (path_conv_10_var.is_owned) {
8649                         path_conv_10_ref |= 1;
8650                 }
8651                 path_arr_ptr[k] = path_conv_10_ref;
8652         }
8653         
8654         FREE(path_var.data);
8655         int64_t short_channel_id_conv = short_channel_id;
8656         js_invoke_function_u_bb(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
8657 }
8658 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8659         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8660         LDKCVec_RouteHopZ path_var = path;
8661         uint32_tArray path_arr = NULL;
8662         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8663         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8664         for (size_t k = 0; k < path_var.datalen; k++) {
8665                 LDKRouteHop path_conv_10_var = path_var.data[k];
8666                 uint32_t path_conv_10_ref = 0;
8667                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8668                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8670                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8671                 if (path_conv_10_var.is_owned) {
8672                         path_conv_10_ref |= 1;
8673                 }
8674                 path_arr_ptr[k] = path_conv_10_ref;
8675         }
8676         
8677         FREE(path_var.data);
8678         js_invoke_function_u_u(j_calls->instance_ptr, 39, (uint32_t)path_arr);
8679 }
8680 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8681         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8682         LDKCVec_RouteHopZ path_var = path;
8683         uint32_tArray path_arr = NULL;
8684         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8685         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8686         for (size_t k = 0; k < path_var.datalen; k++) {
8687                 LDKRouteHop path_conv_10_var = path_var.data[k];
8688                 uint32_t path_conv_10_ref = 0;
8689                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8690                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8691                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8692                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8693                 if (path_conv_10_var.is_owned) {
8694                         path_conv_10_ref |= 1;
8695                 }
8696                 path_arr_ptr[k] = path_conv_10_ref;
8697         }
8698         
8699         FREE(path_var.data);
8700         int64_t short_channel_id_conv = short_channel_id;
8701         js_invoke_function_u_bb(j_calls->instance_ptr, 40, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
8702 }
8703 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8704         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8705         LDKCVec_RouteHopZ path_var = path;
8706         uint32_tArray path_arr = NULL;
8707         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8708         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8709         for (size_t k = 0; k < path_var.datalen; k++) {
8710                 LDKRouteHop path_conv_10_var = path_var.data[k];
8711                 uint32_t path_conv_10_ref = 0;
8712                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8713                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8714                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8715                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8716                 if (path_conv_10_var.is_owned) {
8717                         path_conv_10_ref |= 1;
8718                 }
8719                 path_arr_ptr[k] = path_conv_10_ref;
8720         }
8721         
8722         FREE(path_var.data);
8723         js_invoke_function_u_u(j_calls->instance_ptr, 41, (uint32_t)path_arr);
8724 }
8725 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8726         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8727         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 42);
8728         LDKCVec_u8Z ret_ref;
8729         ret_ref.datalen = ret->arr_len;
8730         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8731         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8732         return ret_ref;
8733 }
8734 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8735         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8736         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8737 }
8738 static inline LDKScore LDKScore_init (JSValue o) {
8739         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8740         atomic_init(&calls->refcnt, 1);
8741         calls->instance_ptr = o;
8742
8743         LDKScore ret = {
8744                 .this_arg = (void*) calls,
8745                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8746                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8747                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8748                 .probe_failed = probe_failed_LDKScore_jcall,
8749                 .probe_successful = probe_successful_LDKScore_jcall,
8750                 .write = write_LDKScore_jcall,
8751                 .free = LDKScore_JCalls_free,
8752         };
8753         return ret;
8754 }
8755 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8756         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8757         *res_ptr = LDKScore_init(o);
8758         return (long)res_ptr;
8759 }
8760 int64_t  __attribute__((export_name("TS_Score_channel_penalty_msat"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target, uint32_t usage) {
8761         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8762         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8763         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8764         LDKNodeId source_conv;
8765         source_conv.inner = (void*)(source & (~1));
8766         source_conv.is_owned = false;
8767         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8768         LDKNodeId target_conv;
8769         target_conv.inner = (void*)(target & (~1));
8770         target_conv.is_owned = false;
8771         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8772         LDKChannelUsage usage_conv;
8773         usage_conv.inner = (void*)(usage & (~1));
8774         usage_conv.is_owned = (usage & 1) || (usage == 0);
8775         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8776         usage_conv = ChannelUsage_clone(&usage_conv);
8777         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8778         return ret_conv;
8779 }
8780
8781 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) {
8782         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8784         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8785         LDKCVec_RouteHopZ path_constr;
8786         path_constr.datalen = path->arr_len;
8787         if (path_constr.datalen > 0)
8788                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8789         else
8790                 path_constr.data = NULL;
8791         uint32_t* path_vals = path->elems;
8792         for (size_t k = 0; k < path_constr.datalen; k++) {
8793                 uint32_t path_conv_10 = path_vals[k];
8794                 LDKRouteHop path_conv_10_conv;
8795                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8796                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8797                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8798                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8799                 path_constr.data[k] = path_conv_10_conv;
8800         }
8801         FREE(path);
8802         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8803 }
8804
8805 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8806         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8807         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8808         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8809         LDKCVec_RouteHopZ path_constr;
8810         path_constr.datalen = path->arr_len;
8811         if (path_constr.datalen > 0)
8812                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8813         else
8814                 path_constr.data = NULL;
8815         uint32_t* path_vals = path->elems;
8816         for (size_t k = 0; k < path_constr.datalen; k++) {
8817                 uint32_t path_conv_10 = path_vals[k];
8818                 LDKRouteHop path_conv_10_conv;
8819                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8820                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8821                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8822                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8823                 path_constr.data[k] = path_conv_10_conv;
8824         }
8825         FREE(path);
8826         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8827 }
8828
8829 void  __attribute__((export_name("TS_Score_probe_failed"))) TS_Score_probe_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
8830         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8831         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8832         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8833         LDKCVec_RouteHopZ path_constr;
8834         path_constr.datalen = path->arr_len;
8835         if (path_constr.datalen > 0)
8836                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8837         else
8838                 path_constr.data = NULL;
8839         uint32_t* path_vals = path->elems;
8840         for (size_t k = 0; k < path_constr.datalen; k++) {
8841                 uint32_t path_conv_10 = path_vals[k];
8842                 LDKRouteHop path_conv_10_conv;
8843                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8844                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8845                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8846                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8847                 path_constr.data[k] = path_conv_10_conv;
8848         }
8849         FREE(path);
8850         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8851 }
8852
8853 void  __attribute__((export_name("TS_Score_probe_successful"))) TS_Score_probe_successful(uint32_t this_arg, uint32_tArray path) {
8854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8856         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8857         LDKCVec_RouteHopZ path_constr;
8858         path_constr.datalen = path->arr_len;
8859         if (path_constr.datalen > 0)
8860                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8861         else
8862                 path_constr.data = NULL;
8863         uint32_t* path_vals = path->elems;
8864         for (size_t k = 0; k < path_constr.datalen; k++) {
8865                 uint32_t path_conv_10 = path_vals[k];
8866                 LDKRouteHop path_conv_10_conv;
8867                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8868                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8869                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8870                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8871                 path_constr.data[k] = path_conv_10_conv;
8872         }
8873         FREE(path);
8874         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
8875 }
8876
8877 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8878         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8879         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8880         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8881         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8884         CVec_u8Z_free(ret_var);
8885         return ret_arr;
8886 }
8887
8888 typedef struct LDKPersister_JCalls {
8889         atomic_size_t refcnt;
8890         uint32_t instance_ptr;
8891 } LDKPersister_JCalls;
8892 static void LDKPersister_JCalls_free(void* this_arg) {
8893         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8894         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8895                 FREE(j_calls);
8896         }
8897 }
8898 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8899         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8900         LDKChannelManager channel_manager_var = *channel_manager;
8901         uint32_t channel_manager_ref = 0;
8902         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8903         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8904         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8905         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8906         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8907         if (channel_manager_var.is_owned) {
8908                 channel_manager_ref |= 1;
8909         }
8910         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 43, (uint32_t)channel_manager_ref);
8911         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8912         CHECK_ACCESS(ret_ptr);
8913         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8914         FREE((void*)ret);
8915         return ret_conv;
8916 }
8917 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8918         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8919         LDKNetworkGraph network_graph_var = *network_graph;
8920         uint32_t network_graph_ref = 0;
8921         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8922         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8923         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8924         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8925         network_graph_ref = (uintptr_t)network_graph_var.inner;
8926         if (network_graph_var.is_owned) {
8927                 network_graph_ref |= 1;
8928         }
8929         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 44, (uint32_t)network_graph_ref);
8930         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8931         CHECK_ACCESS(ret_ptr);
8932         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8933         FREE((void*)ret);
8934         return ret_conv;
8935 }
8936 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8937         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8938         LDKMultiThreadedLockableScore scorer_var = *scorer;
8939         uint32_t scorer_ref = 0;
8940         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8941         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8942         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8943         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8944         scorer_ref = (uintptr_t)scorer_var.inner;
8945         if (scorer_var.is_owned) {
8946                 scorer_ref |= 1;
8947         }
8948         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 45, (uint32_t)scorer_ref);
8949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8950         CHECK_ACCESS(ret_ptr);
8951         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8952         FREE((void*)ret);
8953         return ret_conv;
8954 }
8955 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8956         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8957         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8958 }
8959 static inline LDKPersister LDKPersister_init (JSValue o) {
8960         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8961         atomic_init(&calls->refcnt, 1);
8962         calls->instance_ptr = o;
8963
8964         LDKPersister ret = {
8965                 .this_arg = (void*) calls,
8966                 .persist_manager = persist_manager_LDKPersister_jcall,
8967                 .persist_graph = persist_graph_LDKPersister_jcall,
8968                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8969                 .free = LDKPersister_JCalls_free,
8970         };
8971         return ret;
8972 }
8973 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8974         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8975         *res_ptr = LDKPersister_init(o);
8976         return (long)res_ptr;
8977 }
8978 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8979         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8981         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8982         LDKChannelManager channel_manager_conv;
8983         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8984         channel_manager_conv.is_owned = false;
8985         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8986         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8987         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8988         return (uint32_t)ret_conv;
8989 }
8990
8991 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8992         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8993         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8994         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8995         LDKNetworkGraph network_graph_conv;
8996         network_graph_conv.inner = (void*)(network_graph & (~1));
8997         network_graph_conv.is_owned = false;
8998         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8999         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9000         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
9001         return (uint32_t)ret_conv;
9002 }
9003
9004 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
9005         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9007         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
9008         LDKMultiThreadedLockableScore scorer_conv;
9009         scorer_conv.inner = (void*)(scorer & (~1));
9010         scorer_conv.is_owned = false;
9011         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
9012         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9013         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
9014         return (uint32_t)ret_conv;
9015 }
9016
9017 typedef struct LDKListen_JCalls {
9018         atomic_size_t refcnt;
9019         uint32_t instance_ptr;
9020 } LDKListen_JCalls;
9021 static void LDKListen_JCalls_free(void* this_arg) {
9022         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9023         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9024                 FREE(j_calls);
9025         }
9026 }
9027 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9028         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9029         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9030         memcpy(header_arr->elems, *header, 80);
9031         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9032         uint32_tArray txdata_arr = NULL;
9033         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9034         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
9035         for (size_t c = 0; c < txdata_var.datalen; c++) {
9036                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9037                 *txdata_conv_28_conv = txdata_var.data[c];
9038                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9039         }
9040         
9041         FREE(txdata_var.data);
9042         int32_t height_conv = height;
9043         js_invoke_function_u_uuu(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
9044 }
9045 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9046         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9047         LDKu8slice block_var = block;
9048         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
9049         memcpy(block_arr->elems, block_var.data, block_var.datalen);
9050         int32_t height_conv = height;
9051         js_invoke_function_u_uu(j_calls->instance_ptr, 47, (uint32_t)block_arr, (uint32_t)height_conv);
9052 }
9053 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9054         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9055         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9056         memcpy(header_arr->elems, *header, 80);
9057         int32_t height_conv = height;
9058         js_invoke_function_u_uu(j_calls->instance_ptr, 48, (uint32_t)header_arr, (uint32_t)height_conv);
9059 }
9060 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9061         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9062         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9063 }
9064 static inline LDKListen LDKListen_init (JSValue o) {
9065         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9066         atomic_init(&calls->refcnt, 1);
9067         calls->instance_ptr = o;
9068
9069         LDKListen ret = {
9070                 .this_arg = (void*) calls,
9071                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
9072                 .block_connected = block_connected_LDKListen_jcall,
9073                 .block_disconnected = block_disconnected_LDKListen_jcall,
9074                 .free = LDKListen_JCalls_free,
9075         };
9076         return ret;
9077 }
9078 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
9079         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9080         *res_ptr = LDKListen_init(o);
9081         return (long)res_ptr;
9082 }
9083 void  __attribute__((export_name("TS_Listen_filtered_block_connected"))) TS_Listen_filtered_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9084         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9086         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9087         unsigned char header_arr[80];
9088         CHECK(header->arr_len == 80);
9089         memcpy(header_arr, header->elems, 80); FREE(header);
9090         unsigned char (*header_ref)[80] = &header_arr;
9091         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9092         txdata_constr.datalen = txdata->arr_len;
9093         if (txdata_constr.datalen > 0)
9094                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9095         else
9096                 txdata_constr.data = NULL;
9097         uint32_t* txdata_vals = txdata->elems;
9098         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9099                 uint32_t txdata_conv_28 = txdata_vals[c];
9100                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9101                 CHECK_ACCESS(txdata_conv_28_ptr);
9102                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9103                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9104                 txdata_constr.data[c] = txdata_conv_28_conv;
9105         }
9106         FREE(txdata);
9107         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9108 }
9109
9110 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
9111         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9113         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9114         LDKu8slice block_ref;
9115         block_ref.datalen = block->arr_len;
9116         block_ref.data = block->elems;
9117         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9118         FREE(block);
9119 }
9120
9121 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
9122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9124         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9125         unsigned char header_arr[80];
9126         CHECK(header->arr_len == 80);
9127         memcpy(header_arr, header->elems, 80); FREE(header);
9128         unsigned char (*header_ref)[80] = &header_arr;
9129         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9130 }
9131
9132 typedef struct LDKConfirm_JCalls {
9133         atomic_size_t refcnt;
9134         uint32_t instance_ptr;
9135 } LDKConfirm_JCalls;
9136 static void LDKConfirm_JCalls_free(void* this_arg) {
9137         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9138         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9139                 FREE(j_calls);
9140         }
9141 }
9142 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9143         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9144         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9145         memcpy(header_arr->elems, *header, 80);
9146         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9147         uint32_tArray txdata_arr = NULL;
9148         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9149         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
9150         for (size_t c = 0; c < txdata_var.datalen; c++) {
9151                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9152                 *txdata_conv_28_conv = txdata_var.data[c];
9153                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9154         }
9155         
9156         FREE(txdata_var.data);
9157         int32_t height_conv = height;
9158         js_invoke_function_u_uuu(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
9159 }
9160 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
9161         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9162         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
9163         memcpy(txid_arr->elems, *txid, 32);
9164         js_invoke_function_u_u(j_calls->instance_ptr, 50, (uint32_t)txid_arr);
9165 }
9166 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9167         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9168         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9169         memcpy(header_arr->elems, *header, 80);
9170         int32_t height_conv = height;
9171         js_invoke_function_u_uu(j_calls->instance_ptr, 51, (uint32_t)header_arr, (uint32_t)height_conv);
9172 }
9173 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
9174         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9175         ptrArray ret = (ptrArray)js_invoke_function_u_(j_calls->instance_ptr, 52);
9176         LDKCVec_TxidZ ret_constr;
9177         ret_constr.datalen = ret->arr_len;
9178         if (ret_constr.datalen > 0)
9179                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9180         else
9181                 ret_constr.data = NULL;
9182         int8_tArray* ret_vals = (void*) ret->elems;
9183         for (size_t m = 0; m < ret_constr.datalen; m++) {
9184                 int8_tArray ret_conv_12 = ret_vals[m];
9185                 LDKThirtyTwoBytes ret_conv_12_ref;
9186                 CHECK(ret_conv_12->arr_len == 32);
9187                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
9188                 ret_constr.data[m] = ret_conv_12_ref;
9189         }
9190         FREE(ret);
9191         return ret_constr;
9192 }
9193 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
9194         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
9195         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9196 }
9197 static inline LDKConfirm LDKConfirm_init (JSValue o) {
9198         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
9199         atomic_init(&calls->refcnt, 1);
9200         calls->instance_ptr = o;
9201
9202         LDKConfirm ret = {
9203                 .this_arg = (void*) calls,
9204                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
9205                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
9206                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
9207                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
9208                 .free = LDKConfirm_JCalls_free,
9209         };
9210         return ret;
9211 }
9212 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
9213         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
9214         *res_ptr = LDKConfirm_init(o);
9215         return (long)res_ptr;
9216 }
9217 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) {
9218         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9219         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9220         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9221         unsigned char header_arr[80];
9222         CHECK(header->arr_len == 80);
9223         memcpy(header_arr, header->elems, 80); FREE(header);
9224         unsigned char (*header_ref)[80] = &header_arr;
9225         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9226         txdata_constr.datalen = txdata->arr_len;
9227         if (txdata_constr.datalen > 0)
9228                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9229         else
9230                 txdata_constr.data = NULL;
9231         uint32_t* txdata_vals = txdata->elems;
9232         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9233                 uint32_t txdata_conv_28 = txdata_vals[c];
9234                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9235                 CHECK_ACCESS(txdata_conv_28_ptr);
9236                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9237                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9238                 txdata_constr.data[c] = txdata_conv_28_conv;
9239         }
9240         FREE(txdata);
9241         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9242 }
9243
9244 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
9245         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9246         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9247         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9248         unsigned char txid_arr[32];
9249         CHECK(txid->arr_len == 32);
9250         memcpy(txid_arr, txid->elems, 32); FREE(txid);
9251         unsigned char (*txid_ref)[32] = &txid_arr;
9252         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
9253 }
9254
9255 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
9256         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9257         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9258         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9259         unsigned char header_arr[80];
9260         CHECK(header->arr_len == 80);
9261         memcpy(header_arr, header->elems, 80); FREE(header);
9262         unsigned char (*header_ref)[80] = &header_arr;
9263         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
9264 }
9265
9266 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
9267         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9268         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9269         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9270         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
9271         ptrArray ret_arr = NULL;
9272         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
9273         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
9274         for (size_t m = 0; m < ret_var.datalen; m++) {
9275                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
9276                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
9277                 ret_arr_ptr[m] = ret_conv_12_arr;
9278         }
9279         
9280         FREE(ret_var.data);
9281         return ret_arr;
9282 }
9283
9284 typedef struct LDKPersist_JCalls {
9285         atomic_size_t refcnt;
9286         uint32_t instance_ptr;
9287 } LDKPersist_JCalls;
9288 static void LDKPersist_JCalls_free(void* this_arg) {
9289         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9290         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9291                 FREE(j_calls);
9292         }
9293 }
9294 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9295         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9296         LDKOutPoint channel_id_var = channel_id;
9297         uint32_t channel_id_ref = 0;
9298         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9299         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9300         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9301         channel_id_ref = (uintptr_t)channel_id_var.inner;
9302         if (channel_id_var.is_owned) {
9303                 channel_id_ref |= 1;
9304         }
9305         LDKChannelMonitor data_var = *data;
9306         uint32_t data_ref = 0;
9307         data_var = ChannelMonitor_clone(&data_var);
9308         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9309         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9310         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9311         data_ref = (uintptr_t)data_var.inner;
9312         if (data_var.is_owned) {
9313                 data_ref |= 1;
9314         }
9315         LDKMonitorUpdateId update_id_var = update_id;
9316         uint32_t update_id_ref = 0;
9317         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9318         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9319         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9320         update_id_ref = (uintptr_t)update_id_var.inner;
9321         if (update_id_var.is_owned) {
9322                 update_id_ref |= 1;
9323         }
9324         uint32_t ret = js_invoke_function_u_uuu(j_calls->instance_ptr, 53, (uint32_t)channel_id_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
9325         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9326         CHECK_ACCESS(ret_ptr);
9327         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9328         FREE((void*)ret);
9329         return ret_conv;
9330 }
9331 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9332         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9333         LDKOutPoint channel_id_var = channel_id;
9334         uint32_t channel_id_ref = 0;
9335         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9336         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9337         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9338         channel_id_ref = (uintptr_t)channel_id_var.inner;
9339         if (channel_id_var.is_owned) {
9340                 channel_id_ref |= 1;
9341         }
9342         LDKChannelMonitorUpdate update_var = *update;
9343         uint32_t update_ref = 0;
9344         if ((uintptr_t)update_var.inner > 4096) {
9345                 update_var = ChannelMonitorUpdate_clone(&update_var);
9346                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9347                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9348         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9349                 update_ref = (uintptr_t)update_var.inner;
9350                 if (update_var.is_owned) {
9351                         update_ref |= 1;
9352                 }
9353         }
9354         LDKChannelMonitor data_var = *data;
9355         uint32_t data_ref = 0;
9356         data_var = ChannelMonitor_clone(&data_var);
9357         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9358         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9359         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9360         data_ref = (uintptr_t)data_var.inner;
9361         if (data_var.is_owned) {
9362                 data_ref |= 1;
9363         }
9364         LDKMonitorUpdateId update_id_var = update_id;
9365         uint32_t update_id_ref = 0;
9366         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9367         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9368         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9369         update_id_ref = (uintptr_t)update_id_var.inner;
9370         if (update_id_var.is_owned) {
9371                 update_id_ref |= 1;
9372         }
9373         uint32_t ret = js_invoke_function_u_uuuu(j_calls->instance_ptr, 54, (uint32_t)channel_id_ref, (uint32_t)update_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
9374         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9375         CHECK_ACCESS(ret_ptr);
9376         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9377         FREE((void*)ret);
9378         return ret_conv;
9379 }
9380 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9381         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9383 }
9384 static inline LDKPersist LDKPersist_init (JSValue o) {
9385         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9386         atomic_init(&calls->refcnt, 1);
9387         calls->instance_ptr = o;
9388
9389         LDKPersist ret = {
9390                 .this_arg = (void*) calls,
9391                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9392                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9393                 .free = LDKPersist_JCalls_free,
9394         };
9395         return ret;
9396 }
9397 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9398         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9399         *res_ptr = LDKPersist_init(o);
9400         return (long)res_ptr;
9401 }
9402 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) {
9403         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9404         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9405         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9406         LDKOutPoint channel_id_conv;
9407         channel_id_conv.inner = (void*)(channel_id & (~1));
9408         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9409         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9410         channel_id_conv = OutPoint_clone(&channel_id_conv);
9411         LDKChannelMonitor data_conv;
9412         data_conv.inner = (void*)(data & (~1));
9413         data_conv.is_owned = false;
9414         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9415         LDKMonitorUpdateId update_id_conv;
9416         update_id_conv.inner = (void*)(update_id & (~1));
9417         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9418         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9419         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9420         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9421         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9422         return (uint32_t)ret_conv;
9423 }
9424
9425 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) {
9426         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9428         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9429         LDKOutPoint channel_id_conv;
9430         channel_id_conv.inner = (void*)(channel_id & (~1));
9431         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9432         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9433         channel_id_conv = OutPoint_clone(&channel_id_conv);
9434         LDKChannelMonitorUpdate update_conv;
9435         update_conv.inner = (void*)(update & (~1));
9436         update_conv.is_owned = false;
9437         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9438         LDKChannelMonitor data_conv;
9439         data_conv.inner = (void*)(data & (~1));
9440         data_conv.is_owned = false;
9441         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9442         LDKMonitorUpdateId update_id_conv;
9443         update_id_conv.inner = (void*)(update_id & (~1));
9444         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9445         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9446         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9448         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9449         return (uint32_t)ret_conv;
9450 }
9451
9452 typedef struct LDKChannelMessageHandler_JCalls {
9453         atomic_size_t refcnt;
9454         uint32_t instance_ptr;
9455         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9456 } LDKChannelMessageHandler_JCalls;
9457 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9458         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9459         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9460                 FREE(j_calls);
9461         }
9462 }
9463 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9464         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9465         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9466         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9467         LDKInitFeatures their_features_var = their_features;
9468         uint32_t their_features_ref = 0;
9469         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9470         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9472         their_features_ref = (uintptr_t)their_features_var.inner;
9473         if (their_features_var.is_owned) {
9474                 their_features_ref |= 1;
9475         }
9476         LDKOpenChannel msg_var = *msg;
9477         uint32_t msg_ref = 0;
9478         msg_var = OpenChannel_clone(&msg_var);
9479         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9480         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9481         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9482         msg_ref = (uintptr_t)msg_var.inner;
9483         if (msg_var.is_owned) {
9484                 msg_ref |= 1;
9485         }
9486         js_invoke_function_u_uuu(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9487 }
9488 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9489         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9490         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9491         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9492         LDKInitFeatures their_features_var = their_features;
9493         uint32_t their_features_ref = 0;
9494         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9495         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9496         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9497         their_features_ref = (uintptr_t)their_features_var.inner;
9498         if (their_features_var.is_owned) {
9499                 their_features_ref |= 1;
9500         }
9501         LDKAcceptChannel msg_var = *msg;
9502         uint32_t msg_ref = 0;
9503         msg_var = AcceptChannel_clone(&msg_var);
9504         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9505         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9507         msg_ref = (uintptr_t)msg_var.inner;
9508         if (msg_var.is_owned) {
9509                 msg_ref |= 1;
9510         }
9511         js_invoke_function_u_uuu(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9512 }
9513 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9514         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9515         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9516         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9517         LDKFundingCreated msg_var = *msg;
9518         uint32_t msg_ref = 0;
9519         msg_var = FundingCreated_clone(&msg_var);
9520         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9521         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9523         msg_ref = (uintptr_t)msg_var.inner;
9524         if (msg_var.is_owned) {
9525                 msg_ref |= 1;
9526         }
9527         js_invoke_function_u_uu(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9528 }
9529 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9530         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9531         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9532         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9533         LDKFundingSigned msg_var = *msg;
9534         uint32_t msg_ref = 0;
9535         msg_var = FundingSigned_clone(&msg_var);
9536         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9537         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9539         msg_ref = (uintptr_t)msg_var.inner;
9540         if (msg_var.is_owned) {
9541                 msg_ref |= 1;
9542         }
9543         js_invoke_function_u_uu(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9544 }
9545 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9546         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9547         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9548         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9549         LDKChannelReady msg_var = *msg;
9550         uint32_t msg_ref = 0;
9551         msg_var = ChannelReady_clone(&msg_var);
9552         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9553         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9554         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9555         msg_ref = (uintptr_t)msg_var.inner;
9556         if (msg_var.is_owned) {
9557                 msg_ref |= 1;
9558         }
9559         js_invoke_function_u_uu(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9560 }
9561 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9562         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9563         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9564         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9565         LDKInitFeatures their_features_var = *their_features;
9566         uint32_t their_features_ref = 0;
9567         their_features_var = InitFeatures_clone(&their_features_var);
9568         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9569         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9570         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9571         their_features_ref = (uintptr_t)their_features_var.inner;
9572         if (their_features_var.is_owned) {
9573                 their_features_ref |= 1;
9574         }
9575         LDKShutdown msg_var = *msg;
9576         uint32_t msg_ref = 0;
9577         msg_var = Shutdown_clone(&msg_var);
9578         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9579         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9581         msg_ref = (uintptr_t)msg_var.inner;
9582         if (msg_var.is_owned) {
9583                 msg_ref |= 1;
9584         }
9585         js_invoke_function_u_uuu(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9586 }
9587 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9589         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9590         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9591         LDKClosingSigned msg_var = *msg;
9592         uint32_t msg_ref = 0;
9593         msg_var = ClosingSigned_clone(&msg_var);
9594         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9595         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9597         msg_ref = (uintptr_t)msg_var.inner;
9598         if (msg_var.is_owned) {
9599                 msg_ref |= 1;
9600         }
9601         js_invoke_function_u_uu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9602 }
9603 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9604         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9605         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9606         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9607         LDKUpdateAddHTLC msg_var = *msg;
9608         uint32_t msg_ref = 0;
9609         msg_var = UpdateAddHTLC_clone(&msg_var);
9610         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9611         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9613         msg_ref = (uintptr_t)msg_var.inner;
9614         if (msg_var.is_owned) {
9615                 msg_ref |= 1;
9616         }
9617         js_invoke_function_u_uu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9618 }
9619 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9621         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9622         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9623         LDKUpdateFulfillHTLC msg_var = *msg;
9624         uint32_t msg_ref = 0;
9625         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9626         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9627         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9628         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9629         msg_ref = (uintptr_t)msg_var.inner;
9630         if (msg_var.is_owned) {
9631                 msg_ref |= 1;
9632         }
9633         js_invoke_function_u_uu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9634 }
9635 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9636         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9637         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9638         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9639         LDKUpdateFailHTLC msg_var = *msg;
9640         uint32_t msg_ref = 0;
9641         msg_var = UpdateFailHTLC_clone(&msg_var);
9642         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9643         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9645         msg_ref = (uintptr_t)msg_var.inner;
9646         if (msg_var.is_owned) {
9647                 msg_ref |= 1;
9648         }
9649         js_invoke_function_u_uu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9650 }
9651 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9653         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9654         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9655         LDKUpdateFailMalformedHTLC msg_var = *msg;
9656         uint32_t msg_ref = 0;
9657         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9658         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9659         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9661         msg_ref = (uintptr_t)msg_var.inner;
9662         if (msg_var.is_owned) {
9663                 msg_ref |= 1;
9664         }
9665         js_invoke_function_u_uu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9666 }
9667 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9669         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9670         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9671         LDKCommitmentSigned msg_var = *msg;
9672         uint32_t msg_ref = 0;
9673         msg_var = CommitmentSigned_clone(&msg_var);
9674         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9675         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9677         msg_ref = (uintptr_t)msg_var.inner;
9678         if (msg_var.is_owned) {
9679                 msg_ref |= 1;
9680         }
9681         js_invoke_function_u_uu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9682 }
9683 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9684         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9685         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9686         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9687         LDKRevokeAndACK msg_var = *msg;
9688         uint32_t msg_ref = 0;
9689         msg_var = RevokeAndACK_clone(&msg_var);
9690         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9691         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9693         msg_ref = (uintptr_t)msg_var.inner;
9694         if (msg_var.is_owned) {
9695                 msg_ref |= 1;
9696         }
9697         js_invoke_function_u_uu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9698 }
9699 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9700         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9701         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9702         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9703         LDKUpdateFee msg_var = *msg;
9704         uint32_t msg_ref = 0;
9705         msg_var = UpdateFee_clone(&msg_var);
9706         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9707         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9709         msg_ref = (uintptr_t)msg_var.inner;
9710         if (msg_var.is_owned) {
9711                 msg_ref |= 1;
9712         }
9713         js_invoke_function_u_uu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9714 }
9715 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9717         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9718         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9719         LDKAnnouncementSignatures msg_var = *msg;
9720         uint32_t msg_ref = 0;
9721         msg_var = AnnouncementSignatures_clone(&msg_var);
9722         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9723         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9725         msg_ref = (uintptr_t)msg_var.inner;
9726         if (msg_var.is_owned) {
9727                 msg_ref |= 1;
9728         }
9729         js_invoke_function_u_uu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9730 }
9731 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9732         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9733         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9734         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9735         jboolean no_connection_possible_conv = no_connection_possible;
9736         js_invoke_function_u_uu(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
9737 }
9738 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9739         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9740         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9741         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9742         LDKInit msg_var = *msg;
9743         uint32_t msg_ref = 0;
9744         msg_var = Init_clone(&msg_var);
9745         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9746         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9748         msg_ref = (uintptr_t)msg_var.inner;
9749         if (msg_var.is_owned) {
9750                 msg_ref |= 1;
9751         }
9752         js_invoke_function_u_uu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9753 }
9754 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9755         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9756         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9757         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9758         LDKChannelReestablish msg_var = *msg;
9759         uint32_t msg_ref = 0;
9760         msg_var = ChannelReestablish_clone(&msg_var);
9761         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9762         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9763         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9764         msg_ref = (uintptr_t)msg_var.inner;
9765         if (msg_var.is_owned) {
9766                 msg_ref |= 1;
9767         }
9768         js_invoke_function_u_uu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9769 }
9770 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9771         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9772         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9773         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9774         LDKChannelUpdate msg_var = *msg;
9775         uint32_t msg_ref = 0;
9776         msg_var = ChannelUpdate_clone(&msg_var);
9777         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9778         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9780         msg_ref = (uintptr_t)msg_var.inner;
9781         if (msg_var.is_owned) {
9782                 msg_ref |= 1;
9783         }
9784         js_invoke_function_u_uu(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9785 }
9786 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9787         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9788         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9789         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9790         LDKErrorMessage msg_var = *msg;
9791         uint32_t msg_ref = 0;
9792         msg_var = ErrorMessage_clone(&msg_var);
9793         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9794         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9796         msg_ref = (uintptr_t)msg_var.inner;
9797         if (msg_var.is_owned) {
9798                 msg_ref |= 1;
9799         }
9800         js_invoke_function_u_uu(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9801 }
9802 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9803         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9804         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9805         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9806 }
9807 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9808         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9809         atomic_init(&calls->refcnt, 1);
9810         calls->instance_ptr = o;
9811
9812         LDKChannelMessageHandler ret = {
9813                 .this_arg = (void*) calls,
9814                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9815                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9816                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9817                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9818                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9819                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9820                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9821                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9822                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9823                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9824                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9825                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9826                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9827                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9828                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9829                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9830                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9831                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9832                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9833                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9834                 .free = LDKChannelMessageHandler_JCalls_free,
9835                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9836         };
9837         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9838         return ret;
9839 }
9840 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9841         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9842         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9843         return (long)res_ptr;
9844 }
9845 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) {
9846         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9847         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9848         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9849         LDKPublicKey their_node_id_ref;
9850         CHECK(their_node_id->arr_len == 33);
9851         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9852         LDKInitFeatures their_features_conv;
9853         their_features_conv.inner = (void*)(their_features & (~1));
9854         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9855         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9856         their_features_conv = InitFeatures_clone(&their_features_conv);
9857         LDKOpenChannel msg_conv;
9858         msg_conv.inner = (void*)(msg & (~1));
9859         msg_conv.is_owned = false;
9860         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9861         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9862 }
9863
9864 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) {
9865         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9866         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9867         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9868         LDKPublicKey their_node_id_ref;
9869         CHECK(their_node_id->arr_len == 33);
9870         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9871         LDKInitFeatures their_features_conv;
9872         their_features_conv.inner = (void*)(their_features & (~1));
9873         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9874         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9875         their_features_conv = InitFeatures_clone(&their_features_conv);
9876         LDKAcceptChannel msg_conv;
9877         msg_conv.inner = (void*)(msg & (~1));
9878         msg_conv.is_owned = false;
9879         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9880         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9881 }
9882
9883 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) {
9884         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9885         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9886         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9887         LDKPublicKey their_node_id_ref;
9888         CHECK(their_node_id->arr_len == 33);
9889         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9890         LDKFundingCreated msg_conv;
9891         msg_conv.inner = (void*)(msg & (~1));
9892         msg_conv.is_owned = false;
9893         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9894         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9895 }
9896
9897 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) {
9898         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9899         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9901         LDKPublicKey their_node_id_ref;
9902         CHECK(their_node_id->arr_len == 33);
9903         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9904         LDKFundingSigned msg_conv;
9905         msg_conv.inner = (void*)(msg & (~1));
9906         msg_conv.is_owned = false;
9907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9908         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9909 }
9910
9911 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_ready"))) TS_ChannelMessageHandler_handle_channel_ready(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9912         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9913         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9914         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9915         LDKPublicKey their_node_id_ref;
9916         CHECK(their_node_id->arr_len == 33);
9917         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9918         LDKChannelReady msg_conv;
9919         msg_conv.inner = (void*)(msg & (~1));
9920         msg_conv.is_owned = false;
9921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9922         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9923 }
9924
9925 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) {
9926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9928         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9929         LDKPublicKey their_node_id_ref;
9930         CHECK(their_node_id->arr_len == 33);
9931         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9932         LDKInitFeatures their_features_conv;
9933         their_features_conv.inner = (void*)(their_features & (~1));
9934         their_features_conv.is_owned = false;
9935         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9936         LDKShutdown msg_conv;
9937         msg_conv.inner = (void*)(msg & (~1));
9938         msg_conv.is_owned = false;
9939         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9940         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9941 }
9942
9943 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) {
9944         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9945         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9946         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9947         LDKPublicKey their_node_id_ref;
9948         CHECK(their_node_id->arr_len == 33);
9949         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9950         LDKClosingSigned msg_conv;
9951         msg_conv.inner = (void*)(msg & (~1));
9952         msg_conv.is_owned = false;
9953         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9954         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9955 }
9956
9957 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) {
9958         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9959         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9960         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9961         LDKPublicKey their_node_id_ref;
9962         CHECK(their_node_id->arr_len == 33);
9963         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9964         LDKUpdateAddHTLC msg_conv;
9965         msg_conv.inner = (void*)(msg & (~1));
9966         msg_conv.is_owned = false;
9967         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9968         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9969 }
9970
9971 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) {
9972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9974         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9975         LDKPublicKey their_node_id_ref;
9976         CHECK(their_node_id->arr_len == 33);
9977         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9978         LDKUpdateFulfillHTLC msg_conv;
9979         msg_conv.inner = (void*)(msg & (~1));
9980         msg_conv.is_owned = false;
9981         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9982         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9983 }
9984
9985 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) {
9986         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9987         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9989         LDKPublicKey their_node_id_ref;
9990         CHECK(their_node_id->arr_len == 33);
9991         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9992         LDKUpdateFailHTLC msg_conv;
9993         msg_conv.inner = (void*)(msg & (~1));
9994         msg_conv.is_owned = false;
9995         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9996         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9997 }
9998
9999 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) {
10000         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10001         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10002         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10003         LDKPublicKey their_node_id_ref;
10004         CHECK(their_node_id->arr_len == 33);
10005         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10006         LDKUpdateFailMalformedHTLC msg_conv;
10007         msg_conv.inner = (void*)(msg & (~1));
10008         msg_conv.is_owned = false;
10009         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10010         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10011 }
10012
10013 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) {
10014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10016         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10017         LDKPublicKey their_node_id_ref;
10018         CHECK(their_node_id->arr_len == 33);
10019         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10020         LDKCommitmentSigned msg_conv;
10021         msg_conv.inner = (void*)(msg & (~1));
10022         msg_conv.is_owned = false;
10023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10024         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10025 }
10026
10027 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) {
10028         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10030         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10031         LDKPublicKey their_node_id_ref;
10032         CHECK(their_node_id->arr_len == 33);
10033         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10034         LDKRevokeAndACK msg_conv;
10035         msg_conv.inner = (void*)(msg & (~1));
10036         msg_conv.is_owned = false;
10037         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10038         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10039 }
10040
10041 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) {
10042         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10043         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10044         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10045         LDKPublicKey their_node_id_ref;
10046         CHECK(their_node_id->arr_len == 33);
10047         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10048         LDKUpdateFee msg_conv;
10049         msg_conv.inner = (void*)(msg & (~1));
10050         msg_conv.is_owned = false;
10051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10052         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10053 }
10054
10055 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) {
10056         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10058         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10059         LDKPublicKey their_node_id_ref;
10060         CHECK(their_node_id->arr_len == 33);
10061         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10062         LDKAnnouncementSignatures msg_conv;
10063         msg_conv.inner = (void*)(msg & (~1));
10064         msg_conv.is_owned = false;
10065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10066         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10067 }
10068
10069 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) {
10070         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10071         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10072         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10073         LDKPublicKey their_node_id_ref;
10074         CHECK(their_node_id->arr_len == 33);
10075         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10076         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
10077 }
10078
10079 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10080         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10081         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10082         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10083         LDKPublicKey their_node_id_ref;
10084         CHECK(their_node_id->arr_len == 33);
10085         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10086         LDKInit msg_conv;
10087         msg_conv.inner = (void*)(msg & (~1));
10088         msg_conv.is_owned = false;
10089         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10090         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10091 }
10092
10093 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) {
10094         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10095         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10096         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10097         LDKPublicKey their_node_id_ref;
10098         CHECK(their_node_id->arr_len == 33);
10099         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10100         LDKChannelReestablish msg_conv;
10101         msg_conv.inner = (void*)(msg & (~1));
10102         msg_conv.is_owned = false;
10103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10104         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10105 }
10106
10107 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) {
10108         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10109         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10110         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10111         LDKPublicKey their_node_id_ref;
10112         CHECK(their_node_id->arr_len == 33);
10113         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10114         LDKChannelUpdate msg_conv;
10115         msg_conv.inner = (void*)(msg & (~1));
10116         msg_conv.is_owned = false;
10117         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10118         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10119 }
10120
10121 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10124         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10125         LDKPublicKey their_node_id_ref;
10126         CHECK(their_node_id->arr_len == 33);
10127         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10128         LDKErrorMessage msg_conv;
10129         msg_conv.inner = (void*)(msg & (~1));
10130         msg_conv.is_owned = false;
10131         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10132         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10133 }
10134
10135 typedef struct LDKRoutingMessageHandler_JCalls {
10136         atomic_size_t refcnt;
10137         uint32_t instance_ptr;
10138         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10139 } LDKRoutingMessageHandler_JCalls;
10140 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
10141         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10142         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10143                 FREE(j_calls);
10144         }
10145 }
10146 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
10147         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10148         LDKNodeAnnouncement msg_var = *msg;
10149         uint32_t msg_ref = 0;
10150         msg_var = NodeAnnouncement_clone(&msg_var);
10151         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10152         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10154         msg_ref = (uintptr_t)msg_var.inner;
10155         if (msg_var.is_owned) {
10156                 msg_ref |= 1;
10157         }
10158         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 75, (uint32_t)msg_ref);
10159         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10160         CHECK_ACCESS(ret_ptr);
10161         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10162         FREE((void*)ret);
10163         return ret_conv;
10164 }
10165 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
10166         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10167         LDKChannelAnnouncement msg_var = *msg;
10168         uint32_t msg_ref = 0;
10169         msg_var = ChannelAnnouncement_clone(&msg_var);
10170         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10171         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10172         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10173         msg_ref = (uintptr_t)msg_var.inner;
10174         if (msg_var.is_owned) {
10175                 msg_ref |= 1;
10176         }
10177         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 76, (uint32_t)msg_ref);
10178         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10179         CHECK_ACCESS(ret_ptr);
10180         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10181         FREE((void*)ret);
10182         return ret_conv;
10183 }
10184 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
10185         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10186         LDKChannelUpdate msg_var = *msg;
10187         uint32_t msg_ref = 0;
10188         msg_var = ChannelUpdate_clone(&msg_var);
10189         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10190         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10192         msg_ref = (uintptr_t)msg_var.inner;
10193         if (msg_var.is_owned) {
10194                 msg_ref |= 1;
10195         }
10196         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 77, (uint32_t)msg_ref);
10197         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10198         CHECK_ACCESS(ret_ptr);
10199         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10200         FREE((void*)ret);
10201         return ret_conv;
10202 }
10203 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
10204         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10205         int64_t starting_point_conv = starting_point;
10206         int8_t batch_amount_conv = batch_amount;
10207         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_uu(j_calls->instance_ptr, 78, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv);
10208         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
10209         ret_constr.datalen = ret->arr_len;
10210         if (ret_constr.datalen > 0)
10211                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10212         else
10213                 ret_constr.data = NULL;
10214         uint32_t* ret_vals = ret->elems;
10215         for (size_t h = 0; h < ret_constr.datalen; h++) {
10216                 uint32_t ret_conv_59 = ret_vals[h];
10217                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
10218                 CHECK_ACCESS(ret_conv_59_ptr);
10219                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
10220                 FREE((void*)ret_conv_59);
10221                 ret_constr.data[h] = ret_conv_59_conv;
10222         }
10223         FREE(ret);
10224         return ret_constr;
10225 }
10226 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
10227         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10228         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
10229         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
10230         int8_t batch_amount_conv = batch_amount;
10231         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_uu(j_calls->instance_ptr, 79, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv);
10232         LDKCVec_NodeAnnouncementZ ret_constr;
10233         ret_constr.datalen = ret->arr_len;
10234         if (ret_constr.datalen > 0)
10235                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10236         else
10237                 ret_constr.data = NULL;
10238         uint32_t* ret_vals = ret->elems;
10239         for (size_t s = 0; s < ret_constr.datalen; s++) {
10240                 uint32_t ret_conv_18 = ret_vals[s];
10241                 LDKNodeAnnouncement ret_conv_18_conv;
10242                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
10243                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
10244                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
10245                 ret_constr.data[s] = ret_conv_18_conv;
10246         }
10247         FREE(ret);
10248         return ret_constr;
10249 }
10250 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
10251         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10252         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10253         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10254         LDKInit init_var = *init;
10255         uint32_t init_ref = 0;
10256         init_var = Init_clone(&init_var);
10257         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10258         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10259         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
10260         init_ref = (uintptr_t)init_var.inner;
10261         if (init_var.is_owned) {
10262                 init_ref |= 1;
10263         }
10264         js_invoke_function_u_uu(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
10265 }
10266 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
10267         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10268         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10269         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10270         LDKReplyChannelRange msg_var = msg;
10271         uint32_t msg_ref = 0;
10272         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10273         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10275         msg_ref = (uintptr_t)msg_var.inner;
10276         if (msg_var.is_owned) {
10277                 msg_ref |= 1;
10278         }
10279         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10280         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10281         CHECK_ACCESS(ret_ptr);
10282         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10283         FREE((void*)ret);
10284         return ret_conv;
10285 }
10286 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
10287         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10288         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10289         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10290         LDKReplyShortChannelIdsEnd msg_var = msg;
10291         uint32_t msg_ref = 0;
10292         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10293         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10295         msg_ref = (uintptr_t)msg_var.inner;
10296         if (msg_var.is_owned) {
10297                 msg_ref |= 1;
10298         }
10299         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 82, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10300         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10301         CHECK_ACCESS(ret_ptr);
10302         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10303         FREE((void*)ret);
10304         return ret_conv;
10305 }
10306 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10307         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10308         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10309         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10310         LDKQueryChannelRange msg_var = msg;
10311         uint32_t msg_ref = 0;
10312         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10313         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10314         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10315         msg_ref = (uintptr_t)msg_var.inner;
10316         if (msg_var.is_owned) {
10317                 msg_ref |= 1;
10318         }
10319         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 83, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10320         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10321         CHECK_ACCESS(ret_ptr);
10322         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10323         FREE((void*)ret);
10324         return ret_conv;
10325 }
10326 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10327         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10328         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10329         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10330         LDKQueryShortChannelIds msg_var = msg;
10331         uint32_t msg_ref = 0;
10332         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10333         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10334         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10335         msg_ref = (uintptr_t)msg_var.inner;
10336         if (msg_var.is_owned) {
10337                 msg_ref |= 1;
10338         }
10339         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 84, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10340         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10341         CHECK_ACCESS(ret_ptr);
10342         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10343         FREE((void*)ret);
10344         return ret_conv;
10345 }
10346 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10347         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10348         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10349         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10350 }
10351 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
10352         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10353         atomic_init(&calls->refcnt, 1);
10354         calls->instance_ptr = o;
10355
10356         LDKRoutingMessageHandler ret = {
10357                 .this_arg = (void*) calls,
10358                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10359                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10360                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10361                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10362                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10363                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
10364                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10365                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10366                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10367                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10368                 .free = LDKRoutingMessageHandler_JCalls_free,
10369                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
10370         };
10371         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10372         return ret;
10373 }
10374 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
10375         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10376         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
10377         return (long)res_ptr;
10378 }
10379 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
10380         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10381         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10382         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10383         LDKNodeAnnouncement msg_conv;
10384         msg_conv.inner = (void*)(msg & (~1));
10385         msg_conv.is_owned = false;
10386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10387         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10388         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10389         return (uint32_t)ret_conv;
10390 }
10391
10392 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
10393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10395         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10396         LDKChannelAnnouncement msg_conv;
10397         msg_conv.inner = (void*)(msg & (~1));
10398         msg_conv.is_owned = false;
10399         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10400         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10401         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10402         return (uint32_t)ret_conv;
10403 }
10404
10405 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10406         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10407         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10408         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10409         LDKChannelUpdate msg_conv;
10410         msg_conv.inner = (void*)(msg & (~1));
10411         msg_conv.is_owned = false;
10412         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10413         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10414         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10415         return (uint32_t)ret_conv;
10416 }
10417
10418 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) {
10419         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10420         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10421         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10422         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10423         uint32_tArray ret_arr = NULL;
10424         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10425         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10426         for (size_t h = 0; h < ret_var.datalen; h++) {
10427                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10428                 *ret_conv_59_conv = ret_var.data[h];
10429                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10430         }
10431         
10432         FREE(ret_var.data);
10433         return ret_arr;
10434 }
10435
10436 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) {
10437         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10439         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10440         LDKPublicKey starting_point_ref;
10441         CHECK(starting_point->arr_len == 33);
10442         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10443         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10444         uint32_tArray ret_arr = NULL;
10445         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10446         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10447         for (size_t s = 0; s < ret_var.datalen; s++) {
10448                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10449                 uint32_t ret_conv_18_ref = 0;
10450                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10451                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10453                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10454                 if (ret_conv_18_var.is_owned) {
10455                         ret_conv_18_ref |= 1;
10456                 }
10457                 ret_arr_ptr[s] = ret_conv_18_ref;
10458         }
10459         
10460         FREE(ret_var.data);
10461         return ret_arr;
10462 }
10463
10464 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10467         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10468         LDKPublicKey their_node_id_ref;
10469         CHECK(their_node_id->arr_len == 33);
10470         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10471         LDKInit init_conv;
10472         init_conv.inner = (void*)(init & (~1));
10473         init_conv.is_owned = false;
10474         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10475         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10476 }
10477
10478 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) {
10479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10481         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10482         LDKPublicKey their_node_id_ref;
10483         CHECK(their_node_id->arr_len == 33);
10484         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10485         LDKReplyChannelRange msg_conv;
10486         msg_conv.inner = (void*)(msg & (~1));
10487         msg_conv.is_owned = (msg & 1) || (msg == 0);
10488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10489         msg_conv = ReplyChannelRange_clone(&msg_conv);
10490         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10491         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10492         return (uint32_t)ret_conv;
10493 }
10494
10495 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) {
10496         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10497         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10498         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10499         LDKPublicKey their_node_id_ref;
10500         CHECK(their_node_id->arr_len == 33);
10501         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10502         LDKReplyShortChannelIdsEnd msg_conv;
10503         msg_conv.inner = (void*)(msg & (~1));
10504         msg_conv.is_owned = (msg & 1) || (msg == 0);
10505         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10506         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10507         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10508         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10509         return (uint32_t)ret_conv;
10510 }
10511
10512 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) {
10513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10515         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10516         LDKPublicKey their_node_id_ref;
10517         CHECK(their_node_id->arr_len == 33);
10518         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10519         LDKQueryChannelRange msg_conv;
10520         msg_conv.inner = (void*)(msg & (~1));
10521         msg_conv.is_owned = (msg & 1) || (msg == 0);
10522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10523         msg_conv = QueryChannelRange_clone(&msg_conv);
10524         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10525         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10526         return (uint32_t)ret_conv;
10527 }
10528
10529 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) {
10530         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10532         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10533         LDKPublicKey their_node_id_ref;
10534         CHECK(their_node_id->arr_len == 33);
10535         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10536         LDKQueryShortChannelIds msg_conv;
10537         msg_conv.inner = (void*)(msg & (~1));
10538         msg_conv.is_owned = (msg & 1) || (msg == 0);
10539         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10540         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10541         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10542         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10543         return (uint32_t)ret_conv;
10544 }
10545
10546 typedef struct LDKCustomMessageReader_JCalls {
10547         atomic_size_t refcnt;
10548         uint32_t instance_ptr;
10549 } LDKCustomMessageReader_JCalls;
10550 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10551         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10552         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10553                 FREE(j_calls);
10554         }
10555 }
10556 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10557         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10558         int16_t message_type_conv = message_type;
10559         LDKu8slice buffer_var = buffer;
10560         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10561         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10562         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 85, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
10563         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10564         CHECK_ACCESS(ret_ptr);
10565         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10566         FREE((void*)ret);
10567         return ret_conv;
10568 }
10569 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10570         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10571         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10572 }
10573 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10574         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10575         atomic_init(&calls->refcnt, 1);
10576         calls->instance_ptr = o;
10577
10578         LDKCustomMessageReader ret = {
10579                 .this_arg = (void*) calls,
10580                 .read = read_LDKCustomMessageReader_jcall,
10581                 .free = LDKCustomMessageReader_JCalls_free,
10582         };
10583         return ret;
10584 }
10585 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10586         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10587         *res_ptr = LDKCustomMessageReader_init(o);
10588         return (long)res_ptr;
10589 }
10590 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10593         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10594         LDKu8slice buffer_ref;
10595         buffer_ref.datalen = buffer->arr_len;
10596         buffer_ref.data = buffer->elems;
10597         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10598         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10599         FREE(buffer);
10600         return (uint32_t)ret_conv;
10601 }
10602
10603 typedef struct LDKCustomMessageHandler_JCalls {
10604         atomic_size_t refcnt;
10605         uint32_t instance_ptr;
10606         LDKCustomMessageReader_JCalls* CustomMessageReader;
10607 } LDKCustomMessageHandler_JCalls;
10608 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10609         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10610         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10611                 FREE(j_calls);
10612         }
10613 }
10614 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10615         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10616         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10617         *msg_ret = msg;
10618         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10619         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10620         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 86, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
10621         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10622         CHECK_ACCESS(ret_ptr);
10623         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10624         FREE((void*)ret);
10625         return ret_conv;
10626 }
10627 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10628         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10629         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 87);
10630         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10631         ret_constr.datalen = ret->arr_len;
10632         if (ret_constr.datalen > 0)
10633                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10634         else
10635                 ret_constr.data = NULL;
10636         uint32_t* ret_vals = ret->elems;
10637         for (size_t z = 0; z < ret_constr.datalen; z++) {
10638                 uint32_t ret_conv_25 = ret_vals[z];
10639                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10640                 CHECK_ACCESS(ret_conv_25_ptr);
10641                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10642                 FREE((void*)ret_conv_25);
10643                 ret_constr.data[z] = ret_conv_25_conv;
10644         }
10645         FREE(ret);
10646         return ret_constr;
10647 }
10648 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10649         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10650         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10651         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10652 }
10653 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10654         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10655         atomic_init(&calls->refcnt, 1);
10656         calls->instance_ptr = o;
10657
10658         LDKCustomMessageHandler ret = {
10659                 .this_arg = (void*) calls,
10660                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10661                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10662                 .free = LDKCustomMessageHandler_JCalls_free,
10663                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10664         };
10665         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10666         return ret;
10667 }
10668 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10669         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10670         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10671         return (long)res_ptr;
10672 }
10673 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) {
10674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10676         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10677         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10678         CHECK_ACCESS(msg_ptr);
10679         LDKType msg_conv = *(LDKType*)(msg_ptr);
10680         if (msg_conv.free == LDKType_JCalls_free) {
10681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10682                 LDKType_JCalls_cloned(&msg_conv);
10683         }
10684         LDKPublicKey sender_node_id_ref;
10685         CHECK(sender_node_id->arr_len == 33);
10686         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10687         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10688         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10689         return (uint32_t)ret_conv;
10690 }
10691
10692 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10693         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10694         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10695         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10696         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10697         uint32_tArray ret_arr = NULL;
10698         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10699         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10700         for (size_t z = 0; z < ret_var.datalen; z++) {
10701                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10702                 *ret_conv_25_conv = ret_var.data[z];
10703                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10704         }
10705         
10706         FREE(ret_var.data);
10707         return ret_arr;
10708 }
10709
10710 typedef struct LDKSocketDescriptor_JCalls {
10711         atomic_size_t refcnt;
10712         uint32_t instance_ptr;
10713 } LDKSocketDescriptor_JCalls;
10714 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10715         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10716         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10717                 FREE(j_calls);
10718         }
10719 }
10720 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10721         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10722         LDKu8slice data_var = data;
10723         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10724         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10725         jboolean resume_read_conv = resume_read;
10726         return js_invoke_function_u_uu(j_calls->instance_ptr, 88, (uint32_t)data_arr, (uint32_t)resume_read_conv);
10727 }
10728 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10729         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10730         js_invoke_function_u_(j_calls->instance_ptr, 89);
10731 }
10732 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10733         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10734         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10735         *other_arg_clone = SocketDescriptor_clone(other_arg);
10736         return js_invoke_function_u_u(j_calls->instance_ptr, 90, (uint32_t)(uint32_t)other_arg_clone);
10737 }
10738 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10739         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10740         return js_invoke_function_b_(j_calls->instance_ptr, 91);
10741 }
10742 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10743         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10744         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10745 }
10746 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10747         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10748         atomic_init(&calls->refcnt, 1);
10749         calls->instance_ptr = o;
10750
10751         LDKSocketDescriptor ret = {
10752                 .this_arg = (void*) calls,
10753                 .send_data = send_data_LDKSocketDescriptor_jcall,
10754                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10755                 .eq = eq_LDKSocketDescriptor_jcall,
10756                 .hash = hash_LDKSocketDescriptor_jcall,
10757                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10758                 .free = LDKSocketDescriptor_JCalls_free,
10759         };
10760         return ret;
10761 }
10762 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10763         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10764         *res_ptr = LDKSocketDescriptor_init(o);
10765         return (long)res_ptr;
10766 }
10767 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10768         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10769         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10770         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10771         LDKu8slice data_ref;
10772         data_ref.datalen = data->arr_len;
10773         data_ref.data = data->elems;
10774         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10775         FREE(data);
10776         return ret_conv;
10777 }
10778
10779 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10780         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10781         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10782         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10783         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10784 }
10785
10786 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10787         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10788         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10789         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10790         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10791         return ret_conv;
10792 }
10793
10794 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10795         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10796         switch(obj->tag) {
10797                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10798                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10799                 case LDKEffectiveCapacity_Total: return 2;
10800                 case LDKEffectiveCapacity_Infinite: return 3;
10801                 case LDKEffectiveCapacity_Unknown: return 4;
10802                 default: abort();
10803         }
10804 }
10805 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10806         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10807         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10808                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10809         return liquidity_msat_conv;
10810 }
10811 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10812         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10813         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10814                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10815         return amount_msat_conv;
10816 }
10817 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10818         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10819         assert(obj->tag == LDKEffectiveCapacity_Total);
10820                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10821         return capacity_msat_conv;
10822 }
10823 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint32_t ptr) {
10824         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10825         assert(obj->tag == LDKEffectiveCapacity_Total);
10826                         uint32_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
10827         return htlc_maximum_msat_ref;
10828 }
10829 typedef struct LDKLockableScore_JCalls {
10830         atomic_size_t refcnt;
10831         uint32_t instance_ptr;
10832 } LDKLockableScore_JCalls;
10833 static void LDKLockableScore_JCalls_free(void* this_arg) {
10834         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10835         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10836                 FREE(j_calls);
10837         }
10838 }
10839 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10840         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10841         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 92);
10842         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10843         CHECK_ACCESS(ret_ptr);
10844         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10845         if (ret_conv.free == LDKScore_JCalls_free) {
10846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10847                 LDKScore_JCalls_cloned(&ret_conv);
10848         }// WARNING: we may need a move here but no clone is available for LDKScore
10849         
10850         return ret_conv;
10851 }
10852 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10853         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10854         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10855 }
10856 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10857         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10858         atomic_init(&calls->refcnt, 1);
10859         calls->instance_ptr = o;
10860
10861         LDKLockableScore ret = {
10862                 .this_arg = (void*) calls,
10863                 .lock = lock_LDKLockableScore_jcall,
10864                 .free = LDKLockableScore_JCalls_free,
10865         };
10866         return ret;
10867 }
10868 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10869         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10870         *res_ptr = LDKLockableScore_init(o);
10871         return (long)res_ptr;
10872 }
10873 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10874         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10876         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10877         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10878         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10879         return (uint32_t)ret_ret;
10880 }
10881
10882 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10883         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10884         switch(obj->tag) {
10885                 case LDKFallback_SegWitProgram: return 0;
10886                 case LDKFallback_PubKeyHash: return 1;
10887                 case LDKFallback_ScriptHash: return 2;
10888                 default: abort();
10889         }
10890 }
10891 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10892         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10893         assert(obj->tag == LDKFallback_SegWitProgram);
10894                         uint8_t version_val = obj->seg_wit_program.version._0;
10895         return version_val;
10896 }
10897 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10898         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10899         assert(obj->tag == LDKFallback_SegWitProgram);
10900                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10901                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10902                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10903         return program_arr;
10904 }
10905 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10906         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10907         assert(obj->tag == LDKFallback_PubKeyHash);
10908                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10909                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10910         return pub_key_hash_arr;
10911 }
10912 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10913         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10914         assert(obj->tag == LDKFallback_ScriptHash);
10915                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10916                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10917         return script_hash_arr;
10918 }
10919 typedef struct LDKPayer_JCalls {
10920         atomic_size_t refcnt;
10921         uint32_t instance_ptr;
10922 } LDKPayer_JCalls;
10923 static void LDKPayer_JCalls_free(void* this_arg) {
10924         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10925         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10926                 FREE(j_calls);
10927         }
10928 }
10929 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10930         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10931         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 93);
10932         LDKPublicKey ret_ref;
10933         CHECK(ret->arr_len == 33);
10934         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10935         return ret_ref;
10936 }
10937 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10938         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10939         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 94);
10940         LDKCVec_ChannelDetailsZ ret_constr;
10941         ret_constr.datalen = ret->arr_len;
10942         if (ret_constr.datalen > 0)
10943                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10944         else
10945                 ret_constr.data = NULL;
10946         uint32_t* ret_vals = ret->elems;
10947         for (size_t q = 0; q < ret_constr.datalen; q++) {
10948                 uint32_t ret_conv_16 = ret_vals[q];
10949                 LDKChannelDetails ret_conv_16_conv;
10950                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10951                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10952                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10953                 ret_constr.data[q] = ret_conv_16_conv;
10954         }
10955         FREE(ret);
10956         return ret_constr;
10957 }
10958 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10959         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10960         LDKRoute route_var = *route;
10961         uint32_t route_ref = 0;
10962         route_var = Route_clone(&route_var);
10963         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10964         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10965         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10966         route_ref = (uintptr_t)route_var.inner;
10967         if (route_var.is_owned) {
10968                 route_ref |= 1;
10969         }
10970         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10971         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10972         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10973         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10974         uint32_t ret = js_invoke_function_u_uuu(j_calls->instance_ptr, 95, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr);
10975         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10976         CHECK_ACCESS(ret_ptr);
10977         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10978         FREE((void*)ret);
10979         return ret_conv;
10980 }
10981 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10982         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10983         LDKRoute route_var = *route;
10984         uint32_t route_ref = 0;
10985         route_var = Route_clone(&route_var);
10986         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10987         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10988         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10989         route_ref = (uintptr_t)route_var.inner;
10990         if (route_var.is_owned) {
10991                 route_ref |= 1;
10992         }
10993         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10994         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10995         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 96, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10996         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10997         CHECK_ACCESS(ret_ptr);
10998         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10999         FREE((void*)ret);
11000         return ret_conv;
11001 }
11002 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
11003         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11004         LDKRoute route_var = *route;
11005         uint32_t route_ref = 0;
11006         route_var = Route_clone(&route_var);
11007         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11008         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11009         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11010         route_ref = (uintptr_t)route_var.inner;
11011         if (route_var.is_owned) {
11012                 route_ref |= 1;
11013         }
11014         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11015         memcpy(payment_id_arr->elems, payment_id.data, 32);
11016         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 97, (uint32_t)route_ref, (uint32_t)payment_id_arr);
11017         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11018         CHECK_ACCESS(ret_ptr);
11019         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
11020         FREE((void*)ret);
11021         return ret_conv;
11022 }
11023 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
11024         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11025         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11026         memcpy(payment_id_arr->elems, payment_id.data, 32);
11027         js_invoke_function_u_u(j_calls->instance_ptr, 98, (uint32_t)payment_id_arr);
11028 }
11029 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
11030         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
11031         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11032 }
11033 static inline LDKPayer LDKPayer_init (JSValue o) {
11034         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
11035         atomic_init(&calls->refcnt, 1);
11036         calls->instance_ptr = o;
11037
11038         LDKPayer ret = {
11039                 .this_arg = (void*) calls,
11040                 .node_id = node_id_LDKPayer_jcall,
11041                 .first_hops = first_hops_LDKPayer_jcall,
11042                 .send_payment = send_payment_LDKPayer_jcall,
11043                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
11044                 .retry_payment = retry_payment_LDKPayer_jcall,
11045                 .abandon_payment = abandon_payment_LDKPayer_jcall,
11046                 .free = LDKPayer_JCalls_free,
11047         };
11048         return ret;
11049 }
11050 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
11051         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
11052         *res_ptr = LDKPayer_init(o);
11053         return (long)res_ptr;
11054 }
11055 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
11056         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11058         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11059         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
11060         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
11061         return ret_arr;
11062 }
11063
11064 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
11065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11067         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11068         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
11069         uint32_tArray ret_arr = NULL;
11070         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
11071         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
11072         for (size_t q = 0; q < ret_var.datalen; q++) {
11073                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11074                 uint32_t ret_conv_16_ref = 0;
11075                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11076                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11077                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
11078                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
11079                 if (ret_conv_16_var.is_owned) {
11080                         ret_conv_16_ref |= 1;
11081                 }
11082                 ret_arr_ptr[q] = ret_conv_16_ref;
11083         }
11084         
11085         FREE(ret_var.data);
11086         return ret_arr;
11087 }
11088
11089 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) {
11090         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11091         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11092         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11093         LDKRoute route_conv;
11094         route_conv.inner = (void*)(route & (~1));
11095         route_conv.is_owned = false;
11096         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11097         LDKThirtyTwoBytes payment_hash_ref;
11098         CHECK(payment_hash->arr_len == 32);
11099         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
11100         LDKThirtyTwoBytes payment_secret_ref;
11101         CHECK(payment_secret->arr_len == 32);
11102         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
11103         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11104         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
11105         return (uint32_t)ret_conv;
11106 }
11107
11108 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) {
11109         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11110         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11111         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11112         LDKRoute route_conv;
11113         route_conv.inner = (void*)(route & (~1));
11114         route_conv.is_owned = false;
11115         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11116         LDKThirtyTwoBytes payment_preimage_ref;
11117         CHECK(payment_preimage->arr_len == 32);
11118         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
11119         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11120         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
11121         return (uint32_t)ret_conv;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
11125         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11126         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11127         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11128         LDKRoute route_conv;
11129         route_conv.inner = (void*)(route & (~1));
11130         route_conv.is_owned = false;
11131         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11132         LDKThirtyTwoBytes payment_id_ref;
11133         CHECK(payment_id->arr_len == 32);
11134         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11135         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11136         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
11137         return (uint32_t)ret_conv;
11138 }
11139
11140 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
11141         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11142         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11143         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11144         LDKThirtyTwoBytes payment_id_ref;
11145         CHECK(payment_id->arr_len == 32);
11146         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11147         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
11148 }
11149
11150 typedef struct LDKRouter_JCalls {
11151         atomic_size_t refcnt;
11152         uint32_t instance_ptr;
11153 } LDKRouter_JCalls;
11154 static void LDKRouter_JCalls_free(void* this_arg) {
11155         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11156         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11157                 FREE(j_calls);
11158         }
11159 }
11160 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) {
11161         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11162         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
11163         memcpy(payer_arr->elems, payer.compressed_form, 33);
11164         LDKRouteParameters route_params_var = *route_params;
11165         uint32_t route_params_ref = 0;
11166         route_params_var = RouteParameters_clone(&route_params_var);
11167         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11168         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11169         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
11170         route_params_ref = (uintptr_t)route_params_var.inner;
11171         if (route_params_var.is_owned) {
11172                 route_params_ref |= 1;
11173         }
11174         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
11175         memcpy(payment_hash_arr->elems, *payment_hash, 32);
11176         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
11177         uint32_tArray first_hops_arr = NULL;
11178         if (first_hops != NULL) {
11179                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
11180                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
11181                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
11182                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
11183                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
11184                         uint32_t first_hops_conv_16_ref = 0;
11185                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11186                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11187                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
11188                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
11189                         if (first_hops_conv_16_var.is_owned) {
11190                                 first_hops_conv_16_ref |= 1;
11191                         }
11192                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
11193                 }
11194         
11195         }
11196         // WARNING: This object doesn't live past this scope, needs clone!
11197         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
11198         uint32_t ret = js_invoke_function_u_uuuuu(j_calls->instance_ptr, 99, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer);
11199         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11200         CHECK_ACCESS(ret_ptr);
11201         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
11202         FREE((void*)ret);
11203         return ret_conv;
11204 }
11205 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
11206         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
11207         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11208 }
11209 static inline LDKRouter LDKRouter_init (JSValue o) {
11210         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
11211         atomic_init(&calls->refcnt, 1);
11212         calls->instance_ptr = o;
11213
11214         LDKRouter ret = {
11215                 .this_arg = (void*) calls,
11216                 .find_route = find_route_LDKRouter_jcall,
11217                 .free = LDKRouter_JCalls_free,
11218         };
11219         return ret;
11220 }
11221 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
11222         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
11223         *res_ptr = LDKRouter_init(o);
11224         return (long)res_ptr;
11225 }
11226 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) {
11227         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11228         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11229         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11230         LDKPublicKey payer_ref;
11231         CHECK(payer->arr_len == 33);
11232         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
11233         LDKRouteParameters route_params_conv;
11234         route_params_conv.inner = (void*)(route_params & (~1));
11235         route_params_conv.is_owned = false;
11236         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
11237         unsigned char payment_hash_arr[32];
11238         CHECK(payment_hash->arr_len == 32);
11239         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
11240         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11241         LDKCVec_ChannelDetailsZ first_hops_constr;
11242         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
11243         if (first_hops != 0) {
11244                 first_hops_constr.datalen = first_hops->arr_len;
11245                 if (first_hops_constr.datalen > 0)
11246                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11247                 else
11248                         first_hops_constr.data = NULL;
11249                 uint32_t* first_hops_vals = first_hops->elems;
11250                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11251                         uint32_t first_hops_conv_16 = first_hops_vals[q];
11252                         LDKChannelDetails first_hops_conv_16_conv;
11253                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11254                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11256                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11257                 }
11258                 FREE(first_hops);
11259                 first_hops_ptr = &first_hops_constr;
11260         }
11261         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
11262         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11263         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11264         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11265         *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);
11266         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11267         return (uint32_t)ret_conv;
11268 }
11269
11270 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
11271         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11272         switch(obj->tag) {
11273                 case LDKRetry_Attempts: return 0;
11274                 default: abort();
11275         }
11276 }
11277 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
11278         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11279         assert(obj->tag == LDKRetry_Attempts);
11280                         uint32_t attempts_conv = obj->attempts;
11281         return attempts_conv;
11282 }
11283 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
11284         LDKStr ret_str = _ldk_get_compiled_version();
11285         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11286         Str_free(ret_str);
11287         return ret_conv;
11288 }
11289
11290 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11291         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11292         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11293         Str_free(ret_str);
11294         return ret_conv;
11295 }
11296
11297 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11298         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11299         *ret_copy = Bech32Error_clone(arg);
11300 uint32_t ret_ref = (uintptr_t)ret_copy;
11301         return ret_ref;
11302 }
11303 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
11304         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
11305         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11306         return ret_conv;
11307 }
11308
11309 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
11310         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
11311         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11312         *ret_copy = Bech32Error_clone(orig_conv);
11313         uint32_t ret_ref = (uintptr_t)ret_copy;
11314         return ret_ref;
11315 }
11316
11317 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
11318         if ((o & 1) != 0) return;
11319         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11320         CHECK_ACCESS(o_ptr);
11321         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11322         FREE((void*)o);
11323         Bech32Error_free(o_conv);
11324 }
11325
11326 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11327         LDKTransaction _res_ref;
11328         _res_ref.datalen = _res->arr_len;
11329         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11330         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11331         _res_ref.data_is_owned = true;
11332         Transaction_free(_res_ref);
11333 }
11334
11335 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11336         LDKCVec_u8Z script_pubkey_ref;
11337         script_pubkey_ref.datalen = script_pubkey->arr_len;
11338         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11339         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11340         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11341         *ret_ref = TxOut_new(script_pubkey_ref, value);
11342         return (uint32_t)ret_ref;
11343 }
11344
11345 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
11346         if ((_res & 1) != 0) return;
11347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11348         CHECK_ACCESS(_res_ptr);
11349         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11350         FREE((void*)_res);
11351         TxOut_free(_res_conv);
11352 }
11353
11354 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11355         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11356         *ret_ref = TxOut_clone(arg);
11357         return (uint32_t)ret_ref;
11358 }
11359 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
11360         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11361         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
11362         return ret_conv;
11363 }
11364
11365 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
11366         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11367         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11368         *ret_ref = TxOut_clone(orig_conv);
11369         return (uint32_t)ret_ref;
11370 }
11371
11372 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11373         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11374         Str_free(dummy);
11375 }
11376
11377 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11378         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11379         *ret_conv = CResult_NoneNoneZ_ok();
11380         return (uint32_t)ret_conv;
11381 }
11382
11383 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11384         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11385         *ret_conv = CResult_NoneNoneZ_err();
11386         return (uint32_t)ret_conv;
11387 }
11388
11389 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
11390         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
11391         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11392         return ret_conv;
11393 }
11394
11395 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
11396         if ((_res & 1) != 0) return;
11397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11398         CHECK_ACCESS(_res_ptr);
11399         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11400         FREE((void*)_res);
11401         CResult_NoneNoneZ_free(_res_conv);
11402 }
11403
11404 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11405         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11406         *ret_conv = CResult_NoneNoneZ_clone(arg);
11407         return (uint32_t)ret_conv;
11408 }
11409 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11410         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11411         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11412         return ret_conv;
11413 }
11414
11415 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11416         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11417         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11418         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11419         return (uint32_t)ret_conv;
11420 }
11421
11422 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11423         LDKCounterpartyCommitmentSecrets o_conv;
11424         o_conv.inner = (void*)(o & (~1));
11425         o_conv.is_owned = (o & 1) || (o == 0);
11426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11427         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11428         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11429         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11430         return (uint32_t)ret_conv;
11431 }
11432
11433 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11434         LDKDecodeError e_conv;
11435         e_conv.inner = (void*)(e & (~1));
11436         e_conv.is_owned = (e & 1) || (e == 0);
11437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11438         e_conv = DecodeError_clone(&e_conv);
11439         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11440         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11441         return (uint32_t)ret_conv;
11442 }
11443
11444 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11445         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11446         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11447         return ret_conv;
11448 }
11449
11450 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11451         if ((_res & 1) != 0) return;
11452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11453         CHECK_ACCESS(_res_ptr);
11454         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11455         FREE((void*)_res);
11456         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11457 }
11458
11459 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11460         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11461         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11462         return (uint32_t)ret_conv;
11463 }
11464 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11465         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11466         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11467         return ret_conv;
11468 }
11469
11470 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11471         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11472         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11473         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11474         return (uint32_t)ret_conv;
11475 }
11476
11477 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11478         LDKSecretKey o_ref;
11479         CHECK(o->arr_len == 32);
11480         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11481         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11482         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11483         return (uint32_t)ret_conv;
11484 }
11485
11486 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11487         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11488         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11489         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11490         return (uint32_t)ret_conv;
11491 }
11492
11493 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11494         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11495         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11496         return ret_conv;
11497 }
11498
11499 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11500         if ((_res & 1) != 0) return;
11501         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11502         CHECK_ACCESS(_res_ptr);
11503         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11504         FREE((void*)_res);
11505         CResult_SecretKeyErrorZ_free(_res_conv);
11506 }
11507
11508 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11509         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11510         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11511         return (uint32_t)ret_conv;
11512 }
11513 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11514         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11515         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11516         return ret_conv;
11517 }
11518
11519 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11520         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11521         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11522         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11523         return (uint32_t)ret_conv;
11524 }
11525
11526 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11527         LDKPublicKey o_ref;
11528         CHECK(o->arr_len == 33);
11529         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11530         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11531         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11532         return (uint32_t)ret_conv;
11533 }
11534
11535 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11536         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11537         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11538         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11539         return (uint32_t)ret_conv;
11540 }
11541
11542 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11543         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11544         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11545         return ret_conv;
11546 }
11547
11548 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11549         if ((_res & 1) != 0) return;
11550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11551         CHECK_ACCESS(_res_ptr);
11552         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11553         FREE((void*)_res);
11554         CResult_PublicKeyErrorZ_free(_res_conv);
11555 }
11556
11557 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11558         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11559         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11560         return (uint32_t)ret_conv;
11561 }
11562 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11563         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11564         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11565         return ret_conv;
11566 }
11567
11568 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11569         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11570         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11571         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11572         return (uint32_t)ret_conv;
11573 }
11574
11575 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11576         LDKTxCreationKeys o_conv;
11577         o_conv.inner = (void*)(o & (~1));
11578         o_conv.is_owned = (o & 1) || (o == 0);
11579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11580         o_conv = TxCreationKeys_clone(&o_conv);
11581         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11582         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11583         return (uint32_t)ret_conv;
11584 }
11585
11586 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11587         LDKDecodeError e_conv;
11588         e_conv.inner = (void*)(e & (~1));
11589         e_conv.is_owned = (e & 1) || (e == 0);
11590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11591         e_conv = DecodeError_clone(&e_conv);
11592         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11593         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11594         return (uint32_t)ret_conv;
11595 }
11596
11597 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11598         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11599         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11600         return ret_conv;
11601 }
11602
11603 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11604         if ((_res & 1) != 0) return;
11605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11606         CHECK_ACCESS(_res_ptr);
11607         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11608         FREE((void*)_res);
11609         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11610 }
11611
11612 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11613         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11614         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11615         return (uint32_t)ret_conv;
11616 }
11617 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11618         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11619         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11620         return ret_conv;
11621 }
11622
11623 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11624         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11625         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11626         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11627         return (uint32_t)ret_conv;
11628 }
11629
11630 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11631         LDKChannelPublicKeys o_conv;
11632         o_conv.inner = (void*)(o & (~1));
11633         o_conv.is_owned = (o & 1) || (o == 0);
11634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11635         o_conv = ChannelPublicKeys_clone(&o_conv);
11636         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11637         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11638         return (uint32_t)ret_conv;
11639 }
11640
11641 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11642         LDKDecodeError e_conv;
11643         e_conv.inner = (void*)(e & (~1));
11644         e_conv.is_owned = (e & 1) || (e == 0);
11645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11646         e_conv = DecodeError_clone(&e_conv);
11647         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11648         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11649         return (uint32_t)ret_conv;
11650 }
11651
11652 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11653         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11654         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11655         return ret_conv;
11656 }
11657
11658 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11659         if ((_res & 1) != 0) return;
11660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11661         CHECK_ACCESS(_res_ptr);
11662         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11663         FREE((void*)_res);
11664         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11665 }
11666
11667 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11668         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11669         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11670         return (uint32_t)ret_conv;
11671 }
11672 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11673         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11674         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11675         return ret_conv;
11676 }
11677
11678 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11679         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11680         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11681         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11682         return (uint32_t)ret_conv;
11683 }
11684
11685 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11686         LDKTxCreationKeys o_conv;
11687         o_conv.inner = (void*)(o & (~1));
11688         o_conv.is_owned = (o & 1) || (o == 0);
11689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11690         o_conv = TxCreationKeys_clone(&o_conv);
11691         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11692         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11693         return (uint32_t)ret_conv;
11694 }
11695
11696 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11697         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11698         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11699         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11700         return (uint32_t)ret_conv;
11701 }
11702
11703 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11704         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11705         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11706         return ret_conv;
11707 }
11708
11709 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11710         if ((_res & 1) != 0) return;
11711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11712         CHECK_ACCESS(_res_ptr);
11713         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11714         FREE((void*)_res);
11715         CResult_TxCreationKeysErrorZ_free(_res_conv);
11716 }
11717
11718 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11719         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11720         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11721         return (uint32_t)ret_conv;
11722 }
11723 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11724         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11725         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11726         return ret_conv;
11727 }
11728
11729 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11730         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11731         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11732         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11733         return (uint32_t)ret_conv;
11734 }
11735
11736 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11737         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11738         *ret_copy = COption_u32Z_some(o);
11739         uint32_t ret_ref = (uintptr_t)ret_copy;
11740         return ret_ref;
11741 }
11742
11743 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11744         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11745         *ret_copy = COption_u32Z_none();
11746         uint32_t ret_ref = (uintptr_t)ret_copy;
11747         return ret_ref;
11748 }
11749
11750 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11751         if ((_res & 1) != 0) return;
11752         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11753         CHECK_ACCESS(_res_ptr);
11754         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11755         FREE((void*)_res);
11756         COption_u32Z_free(_res_conv);
11757 }
11758
11759 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11760         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11761         *ret_copy = COption_u32Z_clone(arg);
11762 uint32_t ret_ref = (uintptr_t)ret_copy;
11763         return ret_ref;
11764 }
11765 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11766         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11767         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11768         return ret_conv;
11769 }
11770
11771 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11772         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11773         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11774         *ret_copy = COption_u32Z_clone(orig_conv);
11775         uint32_t ret_ref = (uintptr_t)ret_copy;
11776         return ret_ref;
11777 }
11778
11779 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11780         LDKHTLCOutputInCommitment o_conv;
11781         o_conv.inner = (void*)(o & (~1));
11782         o_conv.is_owned = (o & 1) || (o == 0);
11783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11784         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11785         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11786         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11787         return (uint32_t)ret_conv;
11788 }
11789
11790 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11791         LDKDecodeError e_conv;
11792         e_conv.inner = (void*)(e & (~1));
11793         e_conv.is_owned = (e & 1) || (e == 0);
11794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11795         e_conv = DecodeError_clone(&e_conv);
11796         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11797         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11798         return (uint32_t)ret_conv;
11799 }
11800
11801 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11802         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11803         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11804         return ret_conv;
11805 }
11806
11807 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11808         if ((_res & 1) != 0) return;
11809         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11810         CHECK_ACCESS(_res_ptr);
11811         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11812         FREE((void*)_res);
11813         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11814 }
11815
11816 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11817         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11818         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11819         return (uint32_t)ret_conv;
11820 }
11821 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11822         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11823         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11824         return ret_conv;
11825 }
11826
11827 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11828         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11829         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11830         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11831         return (uint32_t)ret_conv;
11832 }
11833
11834 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11835         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11836         return ret_conv;
11837 }
11838
11839 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11840         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11841         return ret_conv;
11842 }
11843
11844 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11845         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11846         COption_NoneZ_free(_res_conv);
11847 }
11848
11849 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11850         LDKCounterpartyChannelTransactionParameters o_conv;
11851         o_conv.inner = (void*)(o & (~1));
11852         o_conv.is_owned = (o & 1) || (o == 0);
11853         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11854         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11855         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11856         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11857         return (uint32_t)ret_conv;
11858 }
11859
11860 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11861         LDKDecodeError e_conv;
11862         e_conv.inner = (void*)(e & (~1));
11863         e_conv.is_owned = (e & 1) || (e == 0);
11864         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11865         e_conv = DecodeError_clone(&e_conv);
11866         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11867         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11868         return (uint32_t)ret_conv;
11869 }
11870
11871 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11872         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11873         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11874         return ret_conv;
11875 }
11876
11877 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11878         if ((_res & 1) != 0) return;
11879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11880         CHECK_ACCESS(_res_ptr);
11881         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11882         FREE((void*)_res);
11883         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11884 }
11885
11886 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11887         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11888         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11889         return (uint32_t)ret_conv;
11890 }
11891 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11892         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11893         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11894         return ret_conv;
11895 }
11896
11897 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11898         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11899         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11900         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11901         return (uint32_t)ret_conv;
11902 }
11903
11904 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11905         LDKChannelTransactionParameters o_conv;
11906         o_conv.inner = (void*)(o & (~1));
11907         o_conv.is_owned = (o & 1) || (o == 0);
11908         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11909         o_conv = ChannelTransactionParameters_clone(&o_conv);
11910         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11911         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11912         return (uint32_t)ret_conv;
11913 }
11914
11915 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11916         LDKDecodeError e_conv;
11917         e_conv.inner = (void*)(e & (~1));
11918         e_conv.is_owned = (e & 1) || (e == 0);
11919         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11920         e_conv = DecodeError_clone(&e_conv);
11921         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11922         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11923         return (uint32_t)ret_conv;
11924 }
11925
11926 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11927         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11928         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11929         return ret_conv;
11930 }
11931
11932 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11933         if ((_res & 1) != 0) return;
11934         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11935         CHECK_ACCESS(_res_ptr);
11936         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11937         FREE((void*)_res);
11938         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11939 }
11940
11941 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11942         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11943         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11944         return (uint32_t)ret_conv;
11945 }
11946 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11947         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11948         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11949         return ret_conv;
11950 }
11951
11952 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11953         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11954         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11955         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11956         return (uint32_t)ret_conv;
11957 }
11958
11959 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11960         LDKCVec_SignatureZ _res_constr;
11961         _res_constr.datalen = _res->arr_len;
11962         if (_res_constr.datalen > 0)
11963                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11964         else
11965                 _res_constr.data = NULL;
11966         int8_tArray* _res_vals = (void*) _res->elems;
11967         for (size_t m = 0; m < _res_constr.datalen; m++) {
11968                 int8_tArray _res_conv_12 = _res_vals[m];
11969                 LDKSignature _res_conv_12_ref;
11970                 CHECK(_res_conv_12->arr_len == 64);
11971                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11972                 _res_constr.data[m] = _res_conv_12_ref;
11973         }
11974         FREE(_res);
11975         CVec_SignatureZ_free(_res_constr);
11976 }
11977
11978 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11979         LDKHolderCommitmentTransaction o_conv;
11980         o_conv.inner = (void*)(o & (~1));
11981         o_conv.is_owned = (o & 1) || (o == 0);
11982         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11983         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11984         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11985         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11986         return (uint32_t)ret_conv;
11987 }
11988
11989 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11990         LDKDecodeError e_conv;
11991         e_conv.inner = (void*)(e & (~1));
11992         e_conv.is_owned = (e & 1) || (e == 0);
11993         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11994         e_conv = DecodeError_clone(&e_conv);
11995         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11996         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11997         return (uint32_t)ret_conv;
11998 }
11999
12000 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12001         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
12002         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12003         return ret_conv;
12004 }
12005
12006 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12007         if ((_res & 1) != 0) return;
12008         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12009         CHECK_ACCESS(_res_ptr);
12010         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12011         FREE((void*)_res);
12012         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
12013 }
12014
12015 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12016         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12017         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
12018         return (uint32_t)ret_conv;
12019 }
12020 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12021         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12022         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12023         return ret_conv;
12024 }
12025
12026 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12027         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12028         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12029         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12030         return (uint32_t)ret_conv;
12031 }
12032
12033 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12034         LDKBuiltCommitmentTransaction o_conv;
12035         o_conv.inner = (void*)(o & (~1));
12036         o_conv.is_owned = (o & 1) || (o == 0);
12037         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12038         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
12039         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12040         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
12041         return (uint32_t)ret_conv;
12042 }
12043
12044 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12045         LDKDecodeError e_conv;
12046         e_conv.inner = (void*)(e & (~1));
12047         e_conv.is_owned = (e & 1) || (e == 0);
12048         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12049         e_conv = DecodeError_clone(&e_conv);
12050         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12051         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
12052         return (uint32_t)ret_conv;
12053 }
12054
12055 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12056         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
12057         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12058         return ret_conv;
12059 }
12060
12061 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12062         if ((_res & 1) != 0) return;
12063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12064         CHECK_ACCESS(_res_ptr);
12065         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12066         FREE((void*)_res);
12067         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
12068 }
12069
12070 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12071         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12072         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
12073         return (uint32_t)ret_conv;
12074 }
12075 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12076         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12077         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12078         return ret_conv;
12079 }
12080
12081 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12082         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12083         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12084         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12085         return (uint32_t)ret_conv;
12086 }
12087
12088 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
12089         LDKTrustedClosingTransaction o_conv;
12090         o_conv.inner = (void*)(o & (~1));
12091         o_conv.is_owned = (o & 1) || (o == 0);
12092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12093         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
12094         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12095         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
12096         return (uint32_t)ret_conv;
12097 }
12098
12099 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
12100         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12101         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
12102         return (uint32_t)ret_conv;
12103 }
12104
12105 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
12106         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
12107         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
12108         return ret_conv;
12109 }
12110
12111 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
12112         if ((_res & 1) != 0) return;
12113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12114         CHECK_ACCESS(_res_ptr);
12115         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
12116         FREE((void*)_res);
12117         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
12118 }
12119
12120 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12121         LDKCommitmentTransaction o_conv;
12122         o_conv.inner = (void*)(o & (~1));
12123         o_conv.is_owned = (o & 1) || (o == 0);
12124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12125         o_conv = CommitmentTransaction_clone(&o_conv);
12126         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12127         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
12128         return (uint32_t)ret_conv;
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12132         LDKDecodeError e_conv;
12133         e_conv.inner = (void*)(e & (~1));
12134         e_conv.is_owned = (e & 1) || (e == 0);
12135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12136         e_conv = DecodeError_clone(&e_conv);
12137         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12138         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
12139         return (uint32_t)ret_conv;
12140 }
12141
12142 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12143         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
12144         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12145         return ret_conv;
12146 }
12147
12148 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12149         if ((_res & 1) != 0) return;
12150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12151         CHECK_ACCESS(_res_ptr);
12152         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
12153         FREE((void*)_res);
12154         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
12155 }
12156
12157 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12158         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12159         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
12160         return (uint32_t)ret_conv;
12161 }
12162 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12163         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
12164         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12165         return ret_conv;
12166 }
12167
12168 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12169         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
12170         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12171         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
12172         return (uint32_t)ret_conv;
12173 }
12174
12175 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
12176         LDKTrustedCommitmentTransaction o_conv;
12177         o_conv.inner = (void*)(o & (~1));
12178         o_conv.is_owned = (o & 1) || (o == 0);
12179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12180         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12181         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12182         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12183         return (uint32_t)ret_conv;
12184 }
12185
12186 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
12187         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12188         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12189         return (uint32_t)ret_conv;
12190 }
12191
12192 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
12193         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
12194         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
12195         return ret_conv;
12196 }
12197
12198 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
12199         if ((_res & 1) != 0) return;
12200         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12201         CHECK_ACCESS(_res_ptr);
12202         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12203         FREE((void*)_res);
12204         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12205 }
12206
12207 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
12208         LDKCVec_SignatureZ o_constr;
12209         o_constr.datalen = o->arr_len;
12210         if (o_constr.datalen > 0)
12211                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12212         else
12213                 o_constr.data = NULL;
12214         int8_tArray* o_vals = (void*) o->elems;
12215         for (size_t m = 0; m < o_constr.datalen; m++) {
12216                 int8_tArray o_conv_12 = o_vals[m];
12217                 LDKSignature o_conv_12_ref;
12218                 CHECK(o_conv_12->arr_len == 64);
12219                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
12220                 o_constr.data[m] = o_conv_12_ref;
12221         }
12222         FREE(o);
12223         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12224         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12225         return (uint32_t)ret_conv;
12226 }
12227
12228 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
12229         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12230         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12231         return (uint32_t)ret_conv;
12232 }
12233
12234 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
12235         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
12236         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
12237         return ret_conv;
12238 }
12239
12240 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
12241         if ((_res & 1) != 0) return;
12242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12243         CHECK_ACCESS(_res_ptr);
12244         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12245         FREE((void*)_res);
12246         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12247 }
12248
12249 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
12250         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12251         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
12252         return (uint32_t)ret_conv;
12253 }
12254 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
12255         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
12256         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
12257         return ret_conv;
12258 }
12259
12260 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
12261         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
12262         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12263         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12264         return (uint32_t)ret_conv;
12265 }
12266
12267 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
12268         LDKShutdownScript o_conv;
12269         o_conv.inner = (void*)(o & (~1));
12270         o_conv.is_owned = (o & 1) || (o == 0);
12271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12272         o_conv = ShutdownScript_clone(&o_conv);
12273         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12274         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12275         return (uint32_t)ret_conv;
12276 }
12277
12278 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
12279         LDKDecodeError e_conv;
12280         e_conv.inner = (void*)(e & (~1));
12281         e_conv.is_owned = (e & 1) || (e == 0);
12282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12283         e_conv = DecodeError_clone(&e_conv);
12284         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12285         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12286         return (uint32_t)ret_conv;
12287 }
12288
12289 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
12290         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12291         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12292         return ret_conv;
12293 }
12294
12295 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
12296         if ((_res & 1) != 0) return;
12297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12298         CHECK_ACCESS(_res_ptr);
12299         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12300         FREE((void*)_res);
12301         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12302 }
12303
12304 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12305         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12306         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12307         return (uint32_t)ret_conv;
12308 }
12309 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
12310         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12311         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12312         return ret_conv;
12313 }
12314
12315 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
12316         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12317         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12318         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12319         return (uint32_t)ret_conv;
12320 }
12321
12322 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
12323         LDKShutdownScript o_conv;
12324         o_conv.inner = (void*)(o & (~1));
12325         o_conv.is_owned = (o & 1) || (o == 0);
12326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12327         o_conv = ShutdownScript_clone(&o_conv);
12328         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12329         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12330         return (uint32_t)ret_conv;
12331 }
12332
12333 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
12334         LDKInvalidShutdownScript e_conv;
12335         e_conv.inner = (void*)(e & (~1));
12336         e_conv.is_owned = (e & 1) || (e == 0);
12337         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12338         e_conv = InvalidShutdownScript_clone(&e_conv);
12339         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12340         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12341         return (uint32_t)ret_conv;
12342 }
12343
12344 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
12345         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12346         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12347         return ret_conv;
12348 }
12349
12350 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
12351         if ((_res & 1) != 0) return;
12352         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12353         CHECK_ACCESS(_res_ptr);
12354         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12355         FREE((void*)_res);
12356         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12357 }
12358
12359 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12360         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12361         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12362         return (uint32_t)ret_conv;
12363 }
12364 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
12365         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12366         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12367         return ret_conv;
12368 }
12369
12370 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
12371         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12372         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12373         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12374         return (uint32_t)ret_conv;
12375 }
12376
12377 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
12378         LDKRouteHop o_conv;
12379         o_conv.inner = (void*)(o & (~1));
12380         o_conv.is_owned = (o & 1) || (o == 0);
12381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12382         o_conv = RouteHop_clone(&o_conv);
12383         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12384         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12385         return (uint32_t)ret_conv;
12386 }
12387
12388 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
12389         LDKDecodeError e_conv;
12390         e_conv.inner = (void*)(e & (~1));
12391         e_conv.is_owned = (e & 1) || (e == 0);
12392         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12393         e_conv = DecodeError_clone(&e_conv);
12394         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12395         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12396         return (uint32_t)ret_conv;
12397 }
12398
12399 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
12400         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12401         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12402         return ret_conv;
12403 }
12404
12405 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12406         if ((_res & 1) != 0) return;
12407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12408         CHECK_ACCESS(_res_ptr);
12409         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12410         FREE((void*)_res);
12411         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12412 }
12413
12414 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12415         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12416         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12417         return (uint32_t)ret_conv;
12418 }
12419 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12420         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12421         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12422         return ret_conv;
12423 }
12424
12425 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12426         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12427         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12428         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12429         return (uint32_t)ret_conv;
12430 }
12431
12432 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12433         LDKCVec_RouteHopZ _res_constr;
12434         _res_constr.datalen = _res->arr_len;
12435         if (_res_constr.datalen > 0)
12436                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12437         else
12438                 _res_constr.data = NULL;
12439         uint32_t* _res_vals = _res->elems;
12440         for (size_t k = 0; k < _res_constr.datalen; k++) {
12441                 uint32_t _res_conv_10 = _res_vals[k];
12442                 LDKRouteHop _res_conv_10_conv;
12443                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12444                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12445                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12446                 _res_constr.data[k] = _res_conv_10_conv;
12447         }
12448         FREE(_res);
12449         CVec_RouteHopZ_free(_res_constr);
12450 }
12451
12452 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12453         LDKCVec_CVec_RouteHopZZ _res_constr;
12454         _res_constr.datalen = _res->arr_len;
12455         if (_res_constr.datalen > 0)
12456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12457         else
12458                 _res_constr.data = NULL;
12459         uint32_tArray* _res_vals = (void*) _res->elems;
12460         for (size_t m = 0; m < _res_constr.datalen; m++) {
12461                 uint32_tArray _res_conv_12 = _res_vals[m];
12462                 LDKCVec_RouteHopZ _res_conv_12_constr;
12463                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12464                 if (_res_conv_12_constr.datalen > 0)
12465                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12466                 else
12467                         _res_conv_12_constr.data = NULL;
12468                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
12469                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12470                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12471                         LDKRouteHop _res_conv_12_conv_10_conv;
12472                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12473                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12474                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12475                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12476                 }
12477                 FREE(_res_conv_12);
12478                 _res_constr.data[m] = _res_conv_12_constr;
12479         }
12480         FREE(_res);
12481         CVec_CVec_RouteHopZZ_free(_res_constr);
12482 }
12483
12484 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12485         LDKRoute o_conv;
12486         o_conv.inner = (void*)(o & (~1));
12487         o_conv.is_owned = (o & 1) || (o == 0);
12488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12489         o_conv = Route_clone(&o_conv);
12490         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12491         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12492         return (uint32_t)ret_conv;
12493 }
12494
12495 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12496         LDKDecodeError e_conv;
12497         e_conv.inner = (void*)(e & (~1));
12498         e_conv.is_owned = (e & 1) || (e == 0);
12499         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12500         e_conv = DecodeError_clone(&e_conv);
12501         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12502         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12503         return (uint32_t)ret_conv;
12504 }
12505
12506 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12507         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12508         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12509         return ret_conv;
12510 }
12511
12512 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12513         if ((_res & 1) != 0) return;
12514         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12515         CHECK_ACCESS(_res_ptr);
12516         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12517         FREE((void*)_res);
12518         CResult_RouteDecodeErrorZ_free(_res_conv);
12519 }
12520
12521 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12522         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12523         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12524         return (uint32_t)ret_conv;
12525 }
12526 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12527         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12528         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12529         return ret_conv;
12530 }
12531
12532 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12533         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12534         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12535         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12536         return (uint32_t)ret_conv;
12537 }
12538
12539 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12540         LDKRouteParameters o_conv;
12541         o_conv.inner = (void*)(o & (~1));
12542         o_conv.is_owned = (o & 1) || (o == 0);
12543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12544         o_conv = RouteParameters_clone(&o_conv);
12545         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12546         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12547         return (uint32_t)ret_conv;
12548 }
12549
12550 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12551         LDKDecodeError e_conv;
12552         e_conv.inner = (void*)(e & (~1));
12553         e_conv.is_owned = (e & 1) || (e == 0);
12554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12555         e_conv = DecodeError_clone(&e_conv);
12556         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12557         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12558         return (uint32_t)ret_conv;
12559 }
12560
12561 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12562         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12563         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12564         return ret_conv;
12565 }
12566
12567 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12568         if ((_res & 1) != 0) return;
12569         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12570         CHECK_ACCESS(_res_ptr);
12571         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12572         FREE((void*)_res);
12573         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12574 }
12575
12576 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12577         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12578         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12579         return (uint32_t)ret_conv;
12580 }
12581 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12582         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12583         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12584         return ret_conv;
12585 }
12586
12587 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12588         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12589         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12590         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12591         return (uint32_t)ret_conv;
12592 }
12593
12594 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12595         LDKCVec_RouteHintZ _res_constr;
12596         _res_constr.datalen = _res->arr_len;
12597         if (_res_constr.datalen > 0)
12598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12599         else
12600                 _res_constr.data = NULL;
12601         uint32_t* _res_vals = _res->elems;
12602         for (size_t l = 0; l < _res_constr.datalen; l++) {
12603                 uint32_t _res_conv_11 = _res_vals[l];
12604                 LDKRouteHint _res_conv_11_conv;
12605                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12606                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12607                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12608                 _res_constr.data[l] = _res_conv_11_conv;
12609         }
12610         FREE(_res);
12611         CVec_RouteHintZ_free(_res_constr);
12612 }
12613
12614 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12615         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12616         *ret_copy = COption_u64Z_some(o);
12617         uint32_t ret_ref = (uintptr_t)ret_copy;
12618         return ret_ref;
12619 }
12620
12621 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12622         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12623         *ret_copy = COption_u64Z_none();
12624         uint32_t ret_ref = (uintptr_t)ret_copy;
12625         return ret_ref;
12626 }
12627
12628 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12629         if ((_res & 1) != 0) return;
12630         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12631         CHECK_ACCESS(_res_ptr);
12632         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12633         FREE((void*)_res);
12634         COption_u64Z_free(_res_conv);
12635 }
12636
12637 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12638         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12639         *ret_copy = COption_u64Z_clone(arg);
12640 uint32_t ret_ref = (uintptr_t)ret_copy;
12641         return ret_ref;
12642 }
12643 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12644         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12645         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12646         return ret_conv;
12647 }
12648
12649 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12650         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12651         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12652         *ret_copy = COption_u64Z_clone(orig_conv);
12653         uint32_t ret_ref = (uintptr_t)ret_copy;
12654         return ret_ref;
12655 }
12656
12657 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12658         LDKCVec_u64Z _res_constr;
12659         _res_constr.datalen = _res->arr_len;
12660         if (_res_constr.datalen > 0)
12661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12662         else
12663                 _res_constr.data = NULL;
12664         int64_t* _res_vals = _res->elems;
12665         for (size_t i = 0; i < _res_constr.datalen; i++) {
12666                 int64_t _res_conv_8 = _res_vals[i];
12667                 _res_constr.data[i] = _res_conv_8;
12668         }
12669         FREE(_res);
12670         CVec_u64Z_free(_res_constr);
12671 }
12672
12673 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12674         LDKPaymentParameters o_conv;
12675         o_conv.inner = (void*)(o & (~1));
12676         o_conv.is_owned = (o & 1) || (o == 0);
12677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12678         o_conv = PaymentParameters_clone(&o_conv);
12679         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12680         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12681         return (uint32_t)ret_conv;
12682 }
12683
12684 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12685         LDKDecodeError e_conv;
12686         e_conv.inner = (void*)(e & (~1));
12687         e_conv.is_owned = (e & 1) || (e == 0);
12688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12689         e_conv = DecodeError_clone(&e_conv);
12690         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12691         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12692         return (uint32_t)ret_conv;
12693 }
12694
12695 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12696         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12697         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12698         return ret_conv;
12699 }
12700
12701 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12702         if ((_res & 1) != 0) return;
12703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12704         CHECK_ACCESS(_res_ptr);
12705         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12706         FREE((void*)_res);
12707         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12708 }
12709
12710 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12711         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12712         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12713         return (uint32_t)ret_conv;
12714 }
12715 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12716         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12717         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12718         return ret_conv;
12719 }
12720
12721 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12722         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12723         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12724         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12725         return (uint32_t)ret_conv;
12726 }
12727
12728 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12729         LDKCVec_RouteHintHopZ _res_constr;
12730         _res_constr.datalen = _res->arr_len;
12731         if (_res_constr.datalen > 0)
12732                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12733         else
12734                 _res_constr.data = NULL;
12735         uint32_t* _res_vals = _res->elems;
12736         for (size_t o = 0; o < _res_constr.datalen; o++) {
12737                 uint32_t _res_conv_14 = _res_vals[o];
12738                 LDKRouteHintHop _res_conv_14_conv;
12739                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12740                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12742                 _res_constr.data[o] = _res_conv_14_conv;
12743         }
12744         FREE(_res);
12745         CVec_RouteHintHopZ_free(_res_constr);
12746 }
12747
12748 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12749         LDKRouteHint o_conv;
12750         o_conv.inner = (void*)(o & (~1));
12751         o_conv.is_owned = (o & 1) || (o == 0);
12752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12753         o_conv = RouteHint_clone(&o_conv);
12754         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12755         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12756         return (uint32_t)ret_conv;
12757 }
12758
12759 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12760         LDKDecodeError e_conv;
12761         e_conv.inner = (void*)(e & (~1));
12762         e_conv.is_owned = (e & 1) || (e == 0);
12763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12764         e_conv = DecodeError_clone(&e_conv);
12765         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12766         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12767         return (uint32_t)ret_conv;
12768 }
12769
12770 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12771         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12772         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12773         return ret_conv;
12774 }
12775
12776 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12777         if ((_res & 1) != 0) return;
12778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12779         CHECK_ACCESS(_res_ptr);
12780         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12781         FREE((void*)_res);
12782         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12783 }
12784
12785 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12786         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12787         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12788         return (uint32_t)ret_conv;
12789 }
12790 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12791         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12792         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12793         return ret_conv;
12794 }
12795
12796 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12797         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12798         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12799         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12800         return (uint32_t)ret_conv;
12801 }
12802
12803 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12804         LDKRouteHintHop o_conv;
12805         o_conv.inner = (void*)(o & (~1));
12806         o_conv.is_owned = (o & 1) || (o == 0);
12807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12808         o_conv = RouteHintHop_clone(&o_conv);
12809         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12810         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12811         return (uint32_t)ret_conv;
12812 }
12813
12814 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12815         LDKDecodeError e_conv;
12816         e_conv.inner = (void*)(e & (~1));
12817         e_conv.is_owned = (e & 1) || (e == 0);
12818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12819         e_conv = DecodeError_clone(&e_conv);
12820         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12821         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12822         return (uint32_t)ret_conv;
12823 }
12824
12825 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12826         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12827         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12828         return ret_conv;
12829 }
12830
12831 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12832         if ((_res & 1) != 0) return;
12833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12834         CHECK_ACCESS(_res_ptr);
12835         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12836         FREE((void*)_res);
12837         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12838 }
12839
12840 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12841         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12842         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12843         return (uint32_t)ret_conv;
12844 }
12845 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12846         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12847         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12848         return ret_conv;
12849 }
12850
12851 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12852         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12853         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12854         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12855         return (uint32_t)ret_conv;
12856 }
12857
12858 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12859         LDKCVec_ChannelDetailsZ _res_constr;
12860         _res_constr.datalen = _res->arr_len;
12861         if (_res_constr.datalen > 0)
12862                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12863         else
12864                 _res_constr.data = NULL;
12865         uint32_t* _res_vals = _res->elems;
12866         for (size_t q = 0; q < _res_constr.datalen; q++) {
12867                 uint32_t _res_conv_16 = _res_vals[q];
12868                 LDKChannelDetails _res_conv_16_conv;
12869                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12870                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12871                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12872                 _res_constr.data[q] = _res_conv_16_conv;
12873         }
12874         FREE(_res);
12875         CVec_ChannelDetailsZ_free(_res_constr);
12876 }
12877
12878 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12879         LDKRoute o_conv;
12880         o_conv.inner = (void*)(o & (~1));
12881         o_conv.is_owned = (o & 1) || (o == 0);
12882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12883         o_conv = Route_clone(&o_conv);
12884         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12885         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12886         return (uint32_t)ret_conv;
12887 }
12888
12889 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12890         LDKLightningError e_conv;
12891         e_conv.inner = (void*)(e & (~1));
12892         e_conv.is_owned = (e & 1) || (e == 0);
12893         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12894         e_conv = LightningError_clone(&e_conv);
12895         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12896         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12897         return (uint32_t)ret_conv;
12898 }
12899
12900 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12901         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12902         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12903         return ret_conv;
12904 }
12905
12906 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12907         if ((_res & 1) != 0) return;
12908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12909         CHECK_ACCESS(_res_ptr);
12910         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12911         FREE((void*)_res);
12912         CResult_RouteLightningErrorZ_free(_res_conv);
12913 }
12914
12915 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12916         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12917         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12918         return (uint32_t)ret_conv;
12919 }
12920 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12921         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12922         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12923         return ret_conv;
12924 }
12925
12926 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12927         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12928         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12929         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12930         return (uint32_t)ret_conv;
12931 }
12932
12933 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12934         LDKCVec_PublicKeyZ _res_constr;
12935         _res_constr.datalen = _res->arr_len;
12936         if (_res_constr.datalen > 0)
12937                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12938         else
12939                 _res_constr.data = NULL;
12940         int8_tArray* _res_vals = (void*) _res->elems;
12941         for (size_t m = 0; m < _res_constr.datalen; m++) {
12942                 int8_tArray _res_conv_12 = _res_vals[m];
12943                 LDKPublicKey _res_conv_12_ref;
12944                 CHECK(_res_conv_12->arr_len == 33);
12945                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12946                 _res_constr.data[m] = _res_conv_12_ref;
12947         }
12948         FREE(_res);
12949         CVec_PublicKeyZ_free(_res_constr);
12950 }
12951
12952 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12953         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12954         CHECK_ACCESS(o_ptr);
12955         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12956         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12957         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12958         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12959         return (uint32_t)ret_conv;
12960 }
12961
12962 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12963         LDKDecodeError e_conv;
12964         e_conv.inner = (void*)(e & (~1));
12965         e_conv.is_owned = (e & 1) || (e == 0);
12966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12967         e_conv = DecodeError_clone(&e_conv);
12968         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12969         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12970         return (uint32_t)ret_conv;
12971 }
12972
12973 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12974         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12975         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12976         return ret_conv;
12977 }
12978
12979 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12980         if ((_res & 1) != 0) return;
12981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12982         CHECK_ACCESS(_res_ptr);
12983         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12984         FREE((void*)_res);
12985         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12986 }
12987
12988 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12989         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12990         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12991         return (uint32_t)ret_conv;
12992 }
12993 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12994         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12995         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12996         return ret_conv;
12997 }
12998
12999 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
13000         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
13001         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
13002         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
13003         return (uint32_t)ret_conv;
13004 }
13005
13006 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
13007         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13008         CHECK_ACCESS(o_ptr);
13009         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
13010         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
13011         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13012         *ret_copy = COption_ClosureReasonZ_some(o_conv);
13013         uint32_t ret_ref = (uintptr_t)ret_copy;
13014         return ret_ref;
13015 }
13016
13017 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
13018         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13019         *ret_copy = COption_ClosureReasonZ_none();
13020         uint32_t ret_ref = (uintptr_t)ret_copy;
13021         return ret_ref;
13022 }
13023
13024 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
13025         if ((_res & 1) != 0) return;
13026         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13027         CHECK_ACCESS(_res_ptr);
13028         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
13029         FREE((void*)_res);
13030         COption_ClosureReasonZ_free(_res_conv);
13031 }
13032
13033 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
13034         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13035         *ret_copy = COption_ClosureReasonZ_clone(arg);
13036 uint32_t ret_ref = (uintptr_t)ret_copy;
13037         return ret_ref;
13038 }
13039 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
13040         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
13041         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
13042         return ret_conv;
13043 }
13044
13045 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
13046         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
13047         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13048         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
13049         uint32_t ret_ref = (uintptr_t)ret_copy;
13050         return ret_ref;
13051 }
13052
13053 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
13054         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13055         CHECK_ACCESS(o_ptr);
13056         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
13057         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
13058         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13059         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
13060         return (uint32_t)ret_conv;
13061 }
13062
13063 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
13064         LDKDecodeError e_conv;
13065         e_conv.inner = (void*)(e & (~1));
13066         e_conv.is_owned = (e & 1) || (e == 0);
13067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13068         e_conv = DecodeError_clone(&e_conv);
13069         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13070         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
13071         return (uint32_t)ret_conv;
13072 }
13073
13074 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
13075         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
13076         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
13077         return ret_conv;
13078 }
13079
13080 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
13081         if ((_res & 1) != 0) return;
13082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13083         CHECK_ACCESS(_res_ptr);
13084         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
13085         FREE((void*)_res);
13086         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
13087 }
13088
13089 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
13090         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13091         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
13092         return (uint32_t)ret_conv;
13093 }
13094 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
13095         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
13096         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
13097         return ret_conv;
13098 }
13099
13100 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
13101         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
13102         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13103         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
13104         return (uint32_t)ret_conv;
13105 }
13106
13107 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_some"))) TS_COption_HTLCDestinationZ_some(uint32_t o) {
13108         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13109         CHECK_ACCESS(o_ptr);
13110         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
13111         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
13112         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13113         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
13114         uint32_t ret_ref = (uintptr_t)ret_copy;
13115         return ret_ref;
13116 }
13117
13118 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_none"))) TS_COption_HTLCDestinationZ_none() {
13119         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13120         *ret_copy = COption_HTLCDestinationZ_none();
13121         uint32_t ret_ref = (uintptr_t)ret_copy;
13122         return ret_ref;
13123 }
13124
13125 void  __attribute__((export_name("TS_COption_HTLCDestinationZ_free"))) TS_COption_HTLCDestinationZ_free(uint32_t _res) {
13126         if ((_res & 1) != 0) return;
13127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13128         CHECK_ACCESS(_res_ptr);
13129         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
13130         FREE((void*)_res);
13131         COption_HTLCDestinationZ_free(_res_conv);
13132 }
13133
13134 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
13135         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13136         *ret_copy = COption_HTLCDestinationZ_clone(arg);
13137 uint32_t ret_ref = (uintptr_t)ret_copy;
13138         return ret_ref;
13139 }
13140 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone_ptr"))) TS_COption_HTLCDestinationZ_clone_ptr(uint32_t arg) {
13141         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
13142         uint32_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
13143         return ret_conv;
13144 }
13145
13146 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone"))) TS_COption_HTLCDestinationZ_clone(uint32_t orig) {
13147         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
13148         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13149         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
13150         uint32_t ret_ref = (uintptr_t)ret_copy;
13151         return ret_ref;
13152 }
13153
13154 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(uint32_t o) {
13155         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13156         CHECK_ACCESS(o_ptr);
13157         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
13158         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
13159         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13160         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
13161         return (uint32_t)ret_conv;
13162 }
13163
13164 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err(uint32_t e) {
13165         LDKDecodeError e_conv;
13166         e_conv.inner = (void*)(e & (~1));
13167         e_conv.is_owned = (e & 1) || (e == 0);
13168         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13169         e_conv = DecodeError_clone(&e_conv);
13170         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13171         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
13172         return (uint32_t)ret_conv;
13173 }
13174
13175 jboolean  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(uint32_t o) {
13176         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
13177         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
13178         return ret_conv;
13179 }
13180
13181 void  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free(uint32_t _res) {
13182         if ((_res & 1) != 0) return;
13183         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13184         CHECK_ACCESS(_res_ptr);
13185         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
13186         FREE((void*)_res);
13187         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
13188 }
13189
13190 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
13191         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13192         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
13193         return (uint32_t)ret_conv;
13194 }
13195 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(uint32_t arg) {
13196         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
13197         uint32_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
13198         return ret_conv;
13199 }
13200
13201 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(uint32_t orig) {
13202         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
13203         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13204         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
13205         return (uint32_t)ret_conv;
13206 }
13207
13208 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
13209         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13210         CHECK_ACCESS(o_ptr);
13211         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
13212         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
13213         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13214         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
13215         uint32_t ret_ref = (uintptr_t)ret_copy;
13216         return ret_ref;
13217 }
13218
13219 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
13220         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13221         *ret_copy = COption_NetworkUpdateZ_none();
13222         uint32_t ret_ref = (uintptr_t)ret_copy;
13223         return ret_ref;
13224 }
13225
13226 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
13227         if ((_res & 1) != 0) return;
13228         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13229         CHECK_ACCESS(_res_ptr);
13230         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
13231         FREE((void*)_res);
13232         COption_NetworkUpdateZ_free(_res_conv);
13233 }
13234
13235 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
13236         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13237         *ret_copy = COption_NetworkUpdateZ_clone(arg);
13238 uint32_t ret_ref = (uintptr_t)ret_copy;
13239         return ret_ref;
13240 }
13241 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
13242         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
13243         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
13244         return ret_conv;
13245 }
13246
13247 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
13248         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
13249         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13250         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
13251         uint32_t ret_ref = (uintptr_t)ret_copy;
13252         return ret_ref;
13253 }
13254
13255 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
13256         LDKCVec_SpendableOutputDescriptorZ _res_constr;
13257         _res_constr.datalen = _res->arr_len;
13258         if (_res_constr.datalen > 0)
13259                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13260         else
13261                 _res_constr.data = NULL;
13262         uint32_t* _res_vals = _res->elems;
13263         for (size_t b = 0; b < _res_constr.datalen; b++) {
13264                 uint32_t _res_conv_27 = _res_vals[b];
13265                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
13266                 CHECK_ACCESS(_res_conv_27_ptr);
13267                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
13268                 FREE((void*)_res_conv_27);
13269                 _res_constr.data[b] = _res_conv_27_conv;
13270         }
13271         FREE(_res);
13272         CVec_SpendableOutputDescriptorZ_free(_res_constr);
13273 }
13274
13275 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
13276         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13277         CHECK_ACCESS(o_ptr);
13278         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
13279         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
13280         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13281         *ret_copy = COption_EventZ_some(o_conv);
13282         uint32_t ret_ref = (uintptr_t)ret_copy;
13283         return ret_ref;
13284 }
13285
13286 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
13287         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13288         *ret_copy = COption_EventZ_none();
13289         uint32_t ret_ref = (uintptr_t)ret_copy;
13290         return ret_ref;
13291 }
13292
13293 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
13294         if ((_res & 1) != 0) return;
13295         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13296         CHECK_ACCESS(_res_ptr);
13297         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
13298         FREE((void*)_res);
13299         COption_EventZ_free(_res_conv);
13300 }
13301
13302 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
13303         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13304         *ret_copy = COption_EventZ_clone(arg);
13305 uint32_t ret_ref = (uintptr_t)ret_copy;
13306         return ret_ref;
13307 }
13308 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
13309         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
13310         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
13311         return ret_conv;
13312 }
13313
13314 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
13315         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
13316         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13317         *ret_copy = COption_EventZ_clone(orig_conv);
13318         uint32_t ret_ref = (uintptr_t)ret_copy;
13319         return ret_ref;
13320 }
13321
13322 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
13323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13324         CHECK_ACCESS(o_ptr);
13325         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
13326         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
13327         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13328         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
13329         return (uint32_t)ret_conv;
13330 }
13331
13332 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
13333         LDKDecodeError e_conv;
13334         e_conv.inner = (void*)(e & (~1));
13335         e_conv.is_owned = (e & 1) || (e == 0);
13336         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13337         e_conv = DecodeError_clone(&e_conv);
13338         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13339         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13340         return (uint32_t)ret_conv;
13341 }
13342
13343 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
13344         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13345         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13346         return ret_conv;
13347 }
13348
13349 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
13350         if ((_res & 1) != 0) return;
13351         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13352         CHECK_ACCESS(_res_ptr);
13353         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13354         FREE((void*)_res);
13355         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13356 }
13357
13358 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13359         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13360         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13361         return (uint32_t)ret_conv;
13362 }
13363 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
13364         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13365         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13366         return ret_conv;
13367 }
13368
13369 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
13370         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13371         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13372         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13373         return (uint32_t)ret_conv;
13374 }
13375
13376 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
13377         LDKCVec_MessageSendEventZ _res_constr;
13378         _res_constr.datalen = _res->arr_len;
13379         if (_res_constr.datalen > 0)
13380                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13381         else
13382                 _res_constr.data = NULL;
13383         uint32_t* _res_vals = _res->elems;
13384         for (size_t s = 0; s < _res_constr.datalen; s++) {
13385                 uint32_t _res_conv_18 = _res_vals[s];
13386                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
13387                 CHECK_ACCESS(_res_conv_18_ptr);
13388                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13389                 FREE((void*)_res_conv_18);
13390                 _res_constr.data[s] = _res_conv_18_conv;
13391         }
13392         FREE(_res);
13393         CVec_MessageSendEventZ_free(_res_constr);
13394 }
13395
13396 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
13397         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13398         CHECK_ACCESS(o_ptr);
13399         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
13400         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
13401         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13402         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
13403         return (uint32_t)ret_conv;
13404 }
13405
13406 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
13407         LDKAccessError e_conv = LDKAccessError_from_js(e);
13408         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13409         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13410         return (uint32_t)ret_conv;
13411 }
13412
13413 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
13414         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13415         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13416         return ret_conv;
13417 }
13418
13419 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
13420         if ((_res & 1) != 0) return;
13421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13422         CHECK_ACCESS(_res_ptr);
13423         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13424         FREE((void*)_res);
13425         CResult_TxOutAccessErrorZ_free(_res_conv);
13426 }
13427
13428 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13429         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13430         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13431         return (uint32_t)ret_conv;
13432 }
13433 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
13434         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13435         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13436         return ret_conv;
13437 }
13438
13439 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
13440         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13441         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13442         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13443         return (uint32_t)ret_conv;
13444 }
13445
13446 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13447         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13448         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13449         return ((uint32_t)ret_conv);
13450 }
13451 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
13452         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13453         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13454         return ret_conv;
13455 }
13456
13457 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
13458         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13459         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13460         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13461         return ((uint32_t)ret_conv);
13462 }
13463
13464 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13465         LDKTransaction b_ref;
13466         b_ref.datalen = b->arr_len;
13467         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13468         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13469         b_ref.data_is_owned = true;
13470         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13471         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13472         return ((uint32_t)ret_conv);
13473 }
13474
13475 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
13476         if ((_res & 1) != 0) return;
13477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13478         CHECK_ACCESS(_res_ptr);
13479         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13480         FREE((void*)_res);
13481         C2Tuple_usizeTransactionZ_free(_res_conv);
13482 }
13483
13484 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
13485         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13486         _res_constr.datalen = _res->arr_len;
13487         if (_res_constr.datalen > 0)
13488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13489         else
13490                 _res_constr.data = NULL;
13491         uint32_t* _res_vals = _res->elems;
13492         for (size_t c = 0; c < _res_constr.datalen; c++) {
13493                 uint32_t _res_conv_28 = _res_vals[c];
13494                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
13495                 CHECK_ACCESS(_res_conv_28_ptr);
13496                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13497                 FREE((void*)_res_conv_28);
13498                 _res_constr.data[c] = _res_conv_28_conv;
13499         }
13500         FREE(_res);
13501         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13502 }
13503
13504 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13505         LDKCVec_TxidZ _res_constr;
13506         _res_constr.datalen = _res->arr_len;
13507         if (_res_constr.datalen > 0)
13508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13509         else
13510                 _res_constr.data = NULL;
13511         int8_tArray* _res_vals = (void*) _res->elems;
13512         for (size_t m = 0; m < _res_constr.datalen; m++) {
13513                 int8_tArray _res_conv_12 = _res_vals[m];
13514                 LDKThirtyTwoBytes _res_conv_12_ref;
13515                 CHECK(_res_conv_12->arr_len == 32);
13516                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13517                 _res_constr.data[m] = _res_conv_12_ref;
13518         }
13519         FREE(_res);
13520         CVec_TxidZ_free(_res_constr);
13521 }
13522
13523 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13524         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13525         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13526         return (uint32_t)ret_conv;
13527 }
13528
13529 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13530         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13531         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13532         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13533         return (uint32_t)ret_conv;
13534 }
13535
13536 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13537         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13538         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13539         return ret_conv;
13540 }
13541
13542 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13543         if ((_res & 1) != 0) return;
13544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13545         CHECK_ACCESS(_res_ptr);
13546         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13547         FREE((void*)_res);
13548         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13549 }
13550
13551 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13552         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13553         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13554         return (uint32_t)ret_conv;
13555 }
13556 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13557         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13558         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13559         return ret_conv;
13560 }
13561
13562 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13563         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13564         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13565         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13566         return (uint32_t)ret_conv;
13567 }
13568
13569 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13570         LDKCVec_MonitorEventZ _res_constr;
13571         _res_constr.datalen = _res->arr_len;
13572         if (_res_constr.datalen > 0)
13573                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13574         else
13575                 _res_constr.data = NULL;
13576         uint32_t* _res_vals = _res->elems;
13577         for (size_t o = 0; o < _res_constr.datalen; o++) {
13578                 uint32_t _res_conv_14 = _res_vals[o];
13579                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13580                 CHECK_ACCESS(_res_conv_14_ptr);
13581                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13582                 FREE((void*)_res_conv_14);
13583                 _res_constr.data[o] = _res_conv_14_conv;
13584         }
13585         FREE(_res);
13586         CVec_MonitorEventZ_free(_res_constr);
13587 }
13588
13589 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
13590         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13591         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
13592         return ((uint32_t)ret_conv);
13593 }
13594 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(uint32_t arg) {
13595         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
13596         uint32_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
13597         return ret_conv;
13598 }
13599
13600 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(uint32_t orig) {
13601         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
13602         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13603         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
13604         return ((uint32_t)ret_conv);
13605 }
13606
13607 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(uint32_t a, uint32_tArray b, int8_tArray c) {
13608         LDKOutPoint a_conv;
13609         a_conv.inner = (void*)(a & (~1));
13610         a_conv.is_owned = (a & 1) || (a == 0);
13611         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13612         a_conv = OutPoint_clone(&a_conv);
13613         LDKCVec_MonitorEventZ b_constr;
13614         b_constr.datalen = b->arr_len;
13615         if (b_constr.datalen > 0)
13616                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13617         else
13618                 b_constr.data = NULL;
13619         uint32_t* b_vals = b->elems;
13620         for (size_t o = 0; o < b_constr.datalen; o++) {
13621                 uint32_t b_conv_14 = b_vals[o];
13622                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13623                 CHECK_ACCESS(b_conv_14_ptr);
13624                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13625                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13626                 b_constr.data[o] = b_conv_14_conv;
13627         }
13628         FREE(b);
13629         LDKPublicKey c_ref;
13630         CHECK(c->arr_len == 33);
13631         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
13632         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13633         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
13634         return ((uint32_t)ret_conv);
13635 }
13636
13637 void  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(uint32_t _res) {
13638         if ((_res & 1) != 0) return;
13639         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13640         CHECK_ACCESS(_res_ptr);
13641         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
13642         FREE((void*)_res);
13643         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
13644 }
13645
13646 void  __attribute__((export_name("TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free"))) TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(uint32_tArray _res) {
13647         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
13648         _res_constr.datalen = _res->arr_len;
13649         if (_res_constr.datalen > 0)
13650                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
13651         else
13652                 _res_constr.data = NULL;
13653         uint32_t* _res_vals = _res->elems;
13654         for (size_t x = 0; x < _res_constr.datalen; x++) {
13655                 uint32_t _res_conv_49 = _res_vals[x];
13656                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
13657                 CHECK_ACCESS(_res_conv_49_ptr);
13658                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
13659                 FREE((void*)_res_conv_49);
13660                 _res_constr.data[x] = _res_conv_49_conv;
13661         }
13662         FREE(_res);
13663         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
13664 }
13665
13666 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13667         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13668         CHECK_ACCESS(o_ptr);
13669         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13670         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13671         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13672         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13673         uint32_t ret_ref = (uintptr_t)ret_copy;
13674         return ret_ref;
13675 }
13676
13677 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13678         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13679         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13680         uint32_t ret_ref = (uintptr_t)ret_copy;
13681         return ret_ref;
13682 }
13683
13684 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13685         if ((_res & 1) != 0) return;
13686         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13687         CHECK_ACCESS(_res_ptr);
13688         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13689         FREE((void*)_res);
13690         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13691 }
13692
13693 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13694         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13695         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13696 uint32_t ret_ref = (uintptr_t)ret_copy;
13697         return ret_ref;
13698 }
13699 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13700         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13701         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13702         return ret_conv;
13703 }
13704
13705 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13706         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13707         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13708         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13709         uint32_t ret_ref = (uintptr_t)ret_copy;
13710         return ret_ref;
13711 }
13712
13713 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13714         LDKFixedPenaltyScorer o_conv;
13715         o_conv.inner = (void*)(o & (~1));
13716         o_conv.is_owned = (o & 1) || (o == 0);
13717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13718         o_conv = FixedPenaltyScorer_clone(&o_conv);
13719         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13720         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13721         return (uint32_t)ret_conv;
13722 }
13723
13724 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13725         LDKDecodeError e_conv;
13726         e_conv.inner = (void*)(e & (~1));
13727         e_conv.is_owned = (e & 1) || (e == 0);
13728         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13729         e_conv = DecodeError_clone(&e_conv);
13730         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13731         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13732         return (uint32_t)ret_conv;
13733 }
13734
13735 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13736         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13737         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13738         return ret_conv;
13739 }
13740
13741 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13742         if ((_res & 1) != 0) return;
13743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13744         CHECK_ACCESS(_res_ptr);
13745         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13746         FREE((void*)_res);
13747         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13748 }
13749
13750 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13751         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13752         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13753         return (uint32_t)ret_conv;
13754 }
13755 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13756         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13757         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13758         return ret_conv;
13759 }
13760
13761 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13762         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13763         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13764         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13765         return (uint32_t)ret_conv;
13766 }
13767
13768 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13769         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13770         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13771         return ((uint32_t)ret_conv);
13772 }
13773 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint32_t arg) {
13774         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
13775         uint32_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13776         return ret_conv;
13777 }
13778
13779 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
13780         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
13781         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13782         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13783         return ((uint32_t)ret_conv);
13784 }
13785
13786 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13787         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13788         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13789         return ((uint32_t)ret_conv);
13790 }
13791
13792 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
13793         if ((_res & 1) != 0) return;
13794         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13795         CHECK_ACCESS(_res_ptr);
13796         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13797         FREE((void*)_res);
13798         C2Tuple_u64u64Z_free(_res_conv);
13799 }
13800
13801 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint32_t o) {
13802         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13803         CHECK_ACCESS(o_ptr);
13804         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13805         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
13806         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13807         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13808         uint32_t ret_ref = (uintptr_t)ret_copy;
13809         return ret_ref;
13810 }
13811
13812 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13813         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13814         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13815         uint32_t ret_ref = (uintptr_t)ret_copy;
13816         return ret_ref;
13817 }
13818
13819 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint32_t _res) {
13820         if ((_res & 1) != 0) return;
13821         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13822         CHECK_ACCESS(_res_ptr);
13823         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13824         FREE((void*)_res);
13825         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13826 }
13827
13828 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13829         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13830         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13831 uint32_t ret_ref = (uintptr_t)ret_copy;
13832         return ret_ref;
13833 }
13834 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint32_t arg) {
13835         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
13836         uint32_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13837         return ret_conv;
13838 }
13839
13840 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint32_t orig) {
13841         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
13842         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13843         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13844         uint32_t ret_ref = (uintptr_t)ret_copy;
13845         return ret_ref;
13846 }
13847
13848 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint32_tArray _res) {
13849         LDKCVec_NodeIdZ _res_constr;
13850         _res_constr.datalen = _res->arr_len;
13851         if (_res_constr.datalen > 0)
13852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13853         else
13854                 _res_constr.data = NULL;
13855         uint32_t* _res_vals = _res->elems;
13856         for (size_t i = 0; i < _res_constr.datalen; i++) {
13857                 uint32_t _res_conv_8 = _res_vals[i];
13858                 LDKNodeId _res_conv_8_conv;
13859                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
13860                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
13861                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13862                 _res_constr.data[i] = _res_conv_8_conv;
13863         }
13864         FREE(_res);
13865         CVec_NodeIdZ_free(_res_constr);
13866 }
13867
13868 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13869         LDKProbabilisticScorer o_conv;
13870         o_conv.inner = (void*)(o & (~1));
13871         o_conv.is_owned = (o & 1) || (o == 0);
13872         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13873         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13874         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13875         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13876         return (uint32_t)ret_conv;
13877 }
13878
13879 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13880         LDKDecodeError e_conv;
13881         e_conv.inner = (void*)(e & (~1));
13882         e_conv.is_owned = (e & 1) || (e == 0);
13883         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13884         e_conv = DecodeError_clone(&e_conv);
13885         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13886         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13887         return (uint32_t)ret_conv;
13888 }
13889
13890 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13891         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13892         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13893         return ret_conv;
13894 }
13895
13896 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13897         if ((_res & 1) != 0) return;
13898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13899         CHECK_ACCESS(_res_ptr);
13900         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13901         FREE((void*)_res);
13902         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13903 }
13904
13905 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13906         LDKInitFeatures o_conv;
13907         o_conv.inner = (void*)(o & (~1));
13908         o_conv.is_owned = (o & 1) || (o == 0);
13909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13910         o_conv = InitFeatures_clone(&o_conv);
13911         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13912         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13913         return (uint32_t)ret_conv;
13914 }
13915
13916 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13917         LDKDecodeError e_conv;
13918         e_conv.inner = (void*)(e & (~1));
13919         e_conv.is_owned = (e & 1) || (e == 0);
13920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13921         e_conv = DecodeError_clone(&e_conv);
13922         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13923         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13924         return (uint32_t)ret_conv;
13925 }
13926
13927 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13928         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13929         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13930         return ret_conv;
13931 }
13932
13933 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
13934         if ((_res & 1) != 0) return;
13935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13936         CHECK_ACCESS(_res_ptr);
13937         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13938         FREE((void*)_res);
13939         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13940 }
13941
13942 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13943         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13944         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13945         return (uint32_t)ret_conv;
13946 }
13947 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13948         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13949         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13950         return ret_conv;
13951 }
13952
13953 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13954         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13955         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13956         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13957         return (uint32_t)ret_conv;
13958 }
13959
13960 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13961         LDKChannelFeatures o_conv;
13962         o_conv.inner = (void*)(o & (~1));
13963         o_conv.is_owned = (o & 1) || (o == 0);
13964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13965         o_conv = ChannelFeatures_clone(&o_conv);
13966         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13967         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13968         return (uint32_t)ret_conv;
13969 }
13970
13971 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13972         LDKDecodeError e_conv;
13973         e_conv.inner = (void*)(e & (~1));
13974         e_conv.is_owned = (e & 1) || (e == 0);
13975         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13976         e_conv = DecodeError_clone(&e_conv);
13977         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13978         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13979         return (uint32_t)ret_conv;
13980 }
13981
13982 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13983         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13984         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13985         return ret_conv;
13986 }
13987
13988 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13989         if ((_res & 1) != 0) return;
13990         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13991         CHECK_ACCESS(_res_ptr);
13992         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13993         FREE((void*)_res);
13994         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13995 }
13996
13997 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13998         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13999         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
14000         return (uint32_t)ret_conv;
14001 }
14002 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14003         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
14004         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14005         return ret_conv;
14006 }
14007
14008 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
14009         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
14010         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
14011         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
14012         return (uint32_t)ret_conv;
14013 }
14014
14015 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
14016         LDKNodeFeatures o_conv;
14017         o_conv.inner = (void*)(o & (~1));
14018         o_conv.is_owned = (o & 1) || (o == 0);
14019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14020         o_conv = NodeFeatures_clone(&o_conv);
14021         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14022         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
14023         return (uint32_t)ret_conv;
14024 }
14025
14026 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
14027         LDKDecodeError e_conv;
14028         e_conv.inner = (void*)(e & (~1));
14029         e_conv.is_owned = (e & 1) || (e == 0);
14030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14031         e_conv = DecodeError_clone(&e_conv);
14032         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14033         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
14034         return (uint32_t)ret_conv;
14035 }
14036
14037 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14038         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
14039         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
14040         return ret_conv;
14041 }
14042
14043 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
14044         if ((_res & 1) != 0) return;
14045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14046         CHECK_ACCESS(_res_ptr);
14047         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
14048         FREE((void*)_res);
14049         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
14050 }
14051
14052 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14053         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14054         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
14055         return (uint32_t)ret_conv;
14056 }
14057 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14058         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
14059         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14060         return ret_conv;
14061 }
14062
14063 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14064         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
14065         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14066         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
14067         return (uint32_t)ret_conv;
14068 }
14069
14070 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
14071         LDKInvoiceFeatures o_conv;
14072         o_conv.inner = (void*)(o & (~1));
14073         o_conv.is_owned = (o & 1) || (o == 0);
14074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14075         o_conv = InvoiceFeatures_clone(&o_conv);
14076         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14077         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
14078         return (uint32_t)ret_conv;
14079 }
14080
14081 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
14082         LDKDecodeError e_conv;
14083         e_conv.inner = (void*)(e & (~1));
14084         e_conv.is_owned = (e & 1) || (e == 0);
14085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14086         e_conv = DecodeError_clone(&e_conv);
14087         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14088         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
14089         return (uint32_t)ret_conv;
14090 }
14091
14092 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14093         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
14094         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
14095         return ret_conv;
14096 }
14097
14098 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
14099         if ((_res & 1) != 0) return;
14100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14101         CHECK_ACCESS(_res_ptr);
14102         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
14103         FREE((void*)_res);
14104         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
14105 }
14106
14107 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14108         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14109         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
14110         return (uint32_t)ret_conv;
14111 }
14112 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14113         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
14114         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14115         return ret_conv;
14116 }
14117
14118 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
14119         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
14120         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14121         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
14122         return (uint32_t)ret_conv;
14123 }
14124
14125 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
14126         LDKChannelTypeFeatures o_conv;
14127         o_conv.inner = (void*)(o & (~1));
14128         o_conv.is_owned = (o & 1) || (o == 0);
14129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14130         o_conv = ChannelTypeFeatures_clone(&o_conv);
14131         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14132         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
14133         return (uint32_t)ret_conv;
14134 }
14135
14136 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
14137         LDKDecodeError e_conv;
14138         e_conv.inner = (void*)(e & (~1));
14139         e_conv.is_owned = (e & 1) || (e == 0);
14140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14141         e_conv = DecodeError_clone(&e_conv);
14142         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14143         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
14144         return (uint32_t)ret_conv;
14145 }
14146
14147 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14148         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
14149         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
14150         return ret_conv;
14151 }
14152
14153 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_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_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
14158         FREE((void*)_res);
14159         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
14160 }
14161
14162 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14163         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14164         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
14165         return (uint32_t)ret_conv;
14166 }
14167 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14168         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
14169         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14170         return ret_conv;
14171 }
14172
14173 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14174         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
14175         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14176         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
14177         return (uint32_t)ret_conv;
14178 }
14179
14180 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
14181         LDKNodeId o_conv;
14182         o_conv.inner = (void*)(o & (~1));
14183         o_conv.is_owned = (o & 1) || (o == 0);
14184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14185         o_conv = NodeId_clone(&o_conv);
14186         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14187         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
14188         return (uint32_t)ret_conv;
14189 }
14190
14191 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
14192         LDKDecodeError e_conv;
14193         e_conv.inner = (void*)(e & (~1));
14194         e_conv.is_owned = (e & 1) || (e == 0);
14195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14196         e_conv = DecodeError_clone(&e_conv);
14197         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14198         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
14199         return (uint32_t)ret_conv;
14200 }
14201
14202 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
14203         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
14204         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
14205         return ret_conv;
14206 }
14207
14208 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
14209         if ((_res & 1) != 0) return;
14210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14211         CHECK_ACCESS(_res_ptr);
14212         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
14213         FREE((void*)_res);
14214         CResult_NodeIdDecodeErrorZ_free(_res_conv);
14215 }
14216
14217 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
14218         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14219         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
14220         return (uint32_t)ret_conv;
14221 }
14222 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
14223         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
14224         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
14225         return ret_conv;
14226 }
14227
14228 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
14229         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
14230         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14231         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
14232         return (uint32_t)ret_conv;
14233 }
14234
14235 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
14236         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14237         CHECK_ACCESS(o_ptr);
14238         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
14239         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
14240         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14241         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
14242         return (uint32_t)ret_conv;
14243 }
14244
14245 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
14246         LDKDecodeError e_conv;
14247         e_conv.inner = (void*)(e & (~1));
14248         e_conv.is_owned = (e & 1) || (e == 0);
14249         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14250         e_conv = DecodeError_clone(&e_conv);
14251         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14252         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
14253         return (uint32_t)ret_conv;
14254 }
14255
14256 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
14257         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
14258         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
14259         return ret_conv;
14260 }
14261
14262 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
14263         if ((_res & 1) != 0) return;
14264         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14265         CHECK_ACCESS(_res_ptr);
14266         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
14267         FREE((void*)_res);
14268         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
14269 }
14270
14271 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
14272         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14273         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
14274         return (uint32_t)ret_conv;
14275 }
14276 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
14277         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
14278         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
14279         return ret_conv;
14280 }
14281
14282 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
14283         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
14284         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14285         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
14286         return (uint32_t)ret_conv;
14287 }
14288
14289 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
14290         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14291         CHECK_ACCESS(o_ptr);
14292         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14293         if (o_conv.free == LDKAccess_JCalls_free) {
14294                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14295                 LDKAccess_JCalls_cloned(&o_conv);
14296         }
14297         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14298         *ret_copy = COption_AccessZ_some(o_conv);
14299         uint32_t ret_ref = (uintptr_t)ret_copy;
14300         return ret_ref;
14301 }
14302
14303 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
14304         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14305         *ret_copy = COption_AccessZ_none();
14306         uint32_t ret_ref = (uintptr_t)ret_copy;
14307         return ret_ref;
14308 }
14309
14310 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
14311         if ((_res & 1) != 0) return;
14312         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14313         CHECK_ACCESS(_res_ptr);
14314         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14315         FREE((void*)_res);
14316         COption_AccessZ_free(_res_conv);
14317 }
14318
14319 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
14320         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14321         *ret_conv = CResult_boolLightningErrorZ_ok(o);
14322         return (uint32_t)ret_conv;
14323 }
14324
14325 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
14326         LDKLightningError e_conv;
14327         e_conv.inner = (void*)(e & (~1));
14328         e_conv.is_owned = (e & 1) || (e == 0);
14329         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14330         e_conv = LightningError_clone(&e_conv);
14331         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14332         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
14333         return (uint32_t)ret_conv;
14334 }
14335
14336 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
14337         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
14338         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
14339         return ret_conv;
14340 }
14341
14342 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
14343         if ((_res & 1) != 0) return;
14344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14345         CHECK_ACCESS(_res_ptr);
14346         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
14347         FREE((void*)_res);
14348         CResult_boolLightningErrorZ_free(_res_conv);
14349 }
14350
14351 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
14352         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14353         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
14354         return (uint32_t)ret_conv;
14355 }
14356 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
14357         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
14358         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
14359         return ret_conv;
14360 }
14361
14362 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
14363         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
14364         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14365         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
14366         return (uint32_t)ret_conv;
14367 }
14368
14369 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
14370         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14371         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
14372         return ((uint32_t)ret_conv);
14373 }
14374 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
14375         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
14376         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
14377         return ret_conv;
14378 }
14379
14380 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
14381         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
14382         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14383         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
14384         return ((uint32_t)ret_conv);
14385 }
14386
14387 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
14388         LDKChannelAnnouncement a_conv;
14389         a_conv.inner = (void*)(a & (~1));
14390         a_conv.is_owned = (a & 1) || (a == 0);
14391         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
14392         a_conv = ChannelAnnouncement_clone(&a_conv);
14393         LDKChannelUpdate b_conv;
14394         b_conv.inner = (void*)(b & (~1));
14395         b_conv.is_owned = (b & 1) || (b == 0);
14396         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14397         b_conv = ChannelUpdate_clone(&b_conv);
14398         LDKChannelUpdate c_conv;
14399         c_conv.inner = (void*)(c & (~1));
14400         c_conv.is_owned = (c & 1) || (c == 0);
14401         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
14402         c_conv = ChannelUpdate_clone(&c_conv);
14403         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14404         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
14405         return ((uint32_t)ret_conv);
14406 }
14407
14408 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
14409         if ((_res & 1) != 0) return;
14410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14411         CHECK_ACCESS(_res_ptr);
14412         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14413         FREE((void*)_res);
14414         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14415 }
14416
14417 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
14418         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
14419         _res_constr.datalen = _res->arr_len;
14420         if (_res_constr.datalen > 0)
14421                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
14422         else
14423                 _res_constr.data = NULL;
14424         uint32_t* _res_vals = _res->elems;
14425         for (size_t h = 0; h < _res_constr.datalen; h++) {
14426                 uint32_t _res_conv_59 = _res_vals[h];
14427                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
14428                 CHECK_ACCESS(_res_conv_59_ptr);
14429                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
14430                 FREE((void*)_res_conv_59);
14431                 _res_constr.data[h] = _res_conv_59_conv;
14432         }
14433         FREE(_res);
14434         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
14435 }
14436
14437 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
14438         LDKCVec_NodeAnnouncementZ _res_constr;
14439         _res_constr.datalen = _res->arr_len;
14440         if (_res_constr.datalen > 0)
14441                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
14442         else
14443                 _res_constr.data = NULL;
14444         uint32_t* _res_vals = _res->elems;
14445         for (size_t s = 0; s < _res_constr.datalen; s++) {
14446                 uint32_t _res_conv_18 = _res_vals[s];
14447                 LDKNodeAnnouncement _res_conv_18_conv;
14448                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
14449                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
14450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
14451                 _res_constr.data[s] = _res_conv_18_conv;
14452         }
14453         FREE(_res);
14454         CVec_NodeAnnouncementZ_free(_res_constr);
14455 }
14456
14457 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14458         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14459         *ret_conv = CResult_NoneLightningErrorZ_ok();
14460         return (uint32_t)ret_conv;
14461 }
14462
14463 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
14464         LDKLightningError e_conv;
14465         e_conv.inner = (void*)(e & (~1));
14466         e_conv.is_owned = (e & 1) || (e == 0);
14467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14468         e_conv = LightningError_clone(&e_conv);
14469         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14470         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14471         return (uint32_t)ret_conv;
14472 }
14473
14474 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
14475         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
14476         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14477         return ret_conv;
14478 }
14479
14480 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
14481         if ((_res & 1) != 0) return;
14482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14483         CHECK_ACCESS(_res_ptr);
14484         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14485         FREE((void*)_res);
14486         CResult_NoneLightningErrorZ_free(_res_conv);
14487 }
14488
14489 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14490         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14491         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14492         return (uint32_t)ret_conv;
14493 }
14494 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
14495         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
14496         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14497         return ret_conv;
14498 }
14499
14500 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
14501         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
14502         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14503         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14504         return (uint32_t)ret_conv;
14505 }
14506
14507 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
14508         LDKChannelUpdateInfo o_conv;
14509         o_conv.inner = (void*)(o & (~1));
14510         o_conv.is_owned = (o & 1) || (o == 0);
14511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14512         o_conv = ChannelUpdateInfo_clone(&o_conv);
14513         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14514         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14515         return (uint32_t)ret_conv;
14516 }
14517
14518 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
14519         LDKDecodeError e_conv;
14520         e_conv.inner = (void*)(e & (~1));
14521         e_conv.is_owned = (e & 1) || (e == 0);
14522         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14523         e_conv = DecodeError_clone(&e_conv);
14524         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14525         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14526         return (uint32_t)ret_conv;
14527 }
14528
14529 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
14530         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
14531         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14532         return ret_conv;
14533 }
14534
14535 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
14536         if ((_res & 1) != 0) return;
14537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14538         CHECK_ACCESS(_res_ptr);
14539         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14540         FREE((void*)_res);
14541         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14542 }
14543
14544 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14545         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14546         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14547         return (uint32_t)ret_conv;
14548 }
14549 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14550         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
14551         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14552         return ret_conv;
14553 }
14554
14555 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
14556         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
14557         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14558         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14559         return (uint32_t)ret_conv;
14560 }
14561
14562 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14563         LDKChannelInfo o_conv;
14564         o_conv.inner = (void*)(o & (~1));
14565         o_conv.is_owned = (o & 1) || (o == 0);
14566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14567         o_conv = ChannelInfo_clone(&o_conv);
14568         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14569         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14570         return (uint32_t)ret_conv;
14571 }
14572
14573 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14574         LDKDecodeError e_conv;
14575         e_conv.inner = (void*)(e & (~1));
14576         e_conv.is_owned = (e & 1) || (e == 0);
14577         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14578         e_conv = DecodeError_clone(&e_conv);
14579         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14580         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14581         return (uint32_t)ret_conv;
14582 }
14583
14584 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14585         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14586         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14587         return ret_conv;
14588 }
14589
14590 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14591         if ((_res & 1) != 0) return;
14592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14593         CHECK_ACCESS(_res_ptr);
14594         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14595         FREE((void*)_res);
14596         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14597 }
14598
14599 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14600         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14601         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14602         return (uint32_t)ret_conv;
14603 }
14604 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14605         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14606         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14607         return ret_conv;
14608 }
14609
14610 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14611         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14612         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14613         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14614         return (uint32_t)ret_conv;
14615 }
14616
14617 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14618         LDKRoutingFees o_conv;
14619         o_conv.inner = (void*)(o & (~1));
14620         o_conv.is_owned = (o & 1) || (o == 0);
14621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14622         o_conv = RoutingFees_clone(&o_conv);
14623         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14624         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14625         return (uint32_t)ret_conv;
14626 }
14627
14628 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14629         LDKDecodeError e_conv;
14630         e_conv.inner = (void*)(e & (~1));
14631         e_conv.is_owned = (e & 1) || (e == 0);
14632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14633         e_conv = DecodeError_clone(&e_conv);
14634         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14635         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14636         return (uint32_t)ret_conv;
14637 }
14638
14639 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14640         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14641         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14642         return ret_conv;
14643 }
14644
14645 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14646         if ((_res & 1) != 0) return;
14647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14648         CHECK_ACCESS(_res_ptr);
14649         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14650         FREE((void*)_res);
14651         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14652 }
14653
14654 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14655         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14656         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14657         return (uint32_t)ret_conv;
14658 }
14659 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14660         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14661         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14662         return ret_conv;
14663 }
14664
14665 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14666         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14667         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14668         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14669         return (uint32_t)ret_conv;
14670 }
14671
14672 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14673         LDKCVec_NetAddressZ _res_constr;
14674         _res_constr.datalen = _res->arr_len;
14675         if (_res_constr.datalen > 0)
14676                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14677         else
14678                 _res_constr.data = NULL;
14679         uint32_t* _res_vals = _res->elems;
14680         for (size_t m = 0; m < _res_constr.datalen; m++) {
14681                 uint32_t _res_conv_12 = _res_vals[m];
14682                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14683                 CHECK_ACCESS(_res_conv_12_ptr);
14684                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14685                 FREE((void*)_res_conv_12);
14686                 _res_constr.data[m] = _res_conv_12_conv;
14687         }
14688         FREE(_res);
14689         CVec_NetAddressZ_free(_res_constr);
14690 }
14691
14692 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14693         LDKNodeAnnouncementInfo o_conv;
14694         o_conv.inner = (void*)(o & (~1));
14695         o_conv.is_owned = (o & 1) || (o == 0);
14696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14697         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14698         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14699         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14700         return (uint32_t)ret_conv;
14701 }
14702
14703 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14704         LDKDecodeError e_conv;
14705         e_conv.inner = (void*)(e & (~1));
14706         e_conv.is_owned = (e & 1) || (e == 0);
14707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14708         e_conv = DecodeError_clone(&e_conv);
14709         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14710         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14711         return (uint32_t)ret_conv;
14712 }
14713
14714 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14715         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14716         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14717         return ret_conv;
14718 }
14719
14720 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14721         if ((_res & 1) != 0) return;
14722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14723         CHECK_ACCESS(_res_ptr);
14724         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14725         FREE((void*)_res);
14726         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14727 }
14728
14729 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14730         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14731         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14732         return (uint32_t)ret_conv;
14733 }
14734 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14735         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14736         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14737         return ret_conv;
14738 }
14739
14740 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14741         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14742         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14743         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14744         return (uint32_t)ret_conv;
14745 }
14746
14747 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint32_t o) {
14748         LDKNodeAlias o_conv;
14749         o_conv.inner = (void*)(o & (~1));
14750         o_conv.is_owned = (o & 1) || (o == 0);
14751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14752         o_conv = NodeAlias_clone(&o_conv);
14753         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14754         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14755         return (uint32_t)ret_conv;
14756 }
14757
14758 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint32_t e) {
14759         LDKDecodeError e_conv;
14760         e_conv.inner = (void*)(e & (~1));
14761         e_conv.is_owned = (e & 1) || (e == 0);
14762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14763         e_conv = DecodeError_clone(&e_conv);
14764         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14765         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14766         return (uint32_t)ret_conv;
14767 }
14768
14769 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint32_t o) {
14770         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
14771         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14772         return ret_conv;
14773 }
14774
14775 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint32_t _res) {
14776         if ((_res & 1) != 0) return;
14777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14778         CHECK_ACCESS(_res_ptr);
14779         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14780         FREE((void*)_res);
14781         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14782 }
14783
14784 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14785         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14786         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14787         return (uint32_t)ret_conv;
14788 }
14789 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint32_t arg) {
14790         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
14791         uint32_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14792         return ret_conv;
14793 }
14794
14795 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint32_t orig) {
14796         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
14797         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14798         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14799         return (uint32_t)ret_conv;
14800 }
14801
14802 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14803         LDKNodeInfo o_conv;
14804         o_conv.inner = (void*)(o & (~1));
14805         o_conv.is_owned = (o & 1) || (o == 0);
14806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14807         o_conv = NodeInfo_clone(&o_conv);
14808         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14809         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14810         return (uint32_t)ret_conv;
14811 }
14812
14813 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14814         LDKDecodeError e_conv;
14815         e_conv.inner = (void*)(e & (~1));
14816         e_conv.is_owned = (e & 1) || (e == 0);
14817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14818         e_conv = DecodeError_clone(&e_conv);
14819         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14820         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14821         return (uint32_t)ret_conv;
14822 }
14823
14824 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14825         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14826         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14827         return ret_conv;
14828 }
14829
14830 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14831         if ((_res & 1) != 0) return;
14832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14833         CHECK_ACCESS(_res_ptr);
14834         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14835         FREE((void*)_res);
14836         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14837 }
14838
14839 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14840         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14841         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14842         return (uint32_t)ret_conv;
14843 }
14844 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14845         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14846         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14847         return ret_conv;
14848 }
14849
14850 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14851         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14852         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14853         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14854         return (uint32_t)ret_conv;
14855 }
14856
14857 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14858         LDKNetworkGraph o_conv;
14859         o_conv.inner = (void*)(o & (~1));
14860         o_conv.is_owned = (o & 1) || (o == 0);
14861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14862         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14863         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14864         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14865         return (uint32_t)ret_conv;
14866 }
14867
14868 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14869         LDKDecodeError e_conv;
14870         e_conv.inner = (void*)(e & (~1));
14871         e_conv.is_owned = (e & 1) || (e == 0);
14872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14873         e_conv = DecodeError_clone(&e_conv);
14874         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14875         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14876         return (uint32_t)ret_conv;
14877 }
14878
14879 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14880         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14881         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14882         return ret_conv;
14883 }
14884
14885 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14886         if ((_res & 1) != 0) return;
14887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14888         CHECK_ACCESS(_res_ptr);
14889         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14890         FREE((void*)_res);
14891         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14892 }
14893
14894 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14895         LDKCVec_NetAddressZ o_constr;
14896         o_constr.datalen = o->arr_len;
14897         if (o_constr.datalen > 0)
14898                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14899         else
14900                 o_constr.data = NULL;
14901         uint32_t* o_vals = o->elems;
14902         for (size_t m = 0; m < o_constr.datalen; m++) {
14903                 uint32_t o_conv_12 = o_vals[m];
14904                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14905                 CHECK_ACCESS(o_conv_12_ptr);
14906                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14907                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14908                 o_constr.data[m] = o_conv_12_conv;
14909         }
14910         FREE(o);
14911         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14912         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14913         uint32_t ret_ref = (uintptr_t)ret_copy;
14914         return ret_ref;
14915 }
14916
14917 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14918         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14919         *ret_copy = COption_CVec_NetAddressZZ_none();
14920         uint32_t ret_ref = (uintptr_t)ret_copy;
14921         return ret_ref;
14922 }
14923
14924 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14925         if ((_res & 1) != 0) return;
14926         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14927         CHECK_ACCESS(_res_ptr);
14928         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14929         FREE((void*)_res);
14930         COption_CVec_NetAddressZZ_free(_res_conv);
14931 }
14932
14933 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14934         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14935         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14936 uint32_t ret_ref = (uintptr_t)ret_copy;
14937         return ret_ref;
14938 }
14939 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14940         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14941         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14942         return ret_conv;
14943 }
14944
14945 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14946         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14947         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14948         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14949         uint32_t ret_ref = (uintptr_t)ret_copy;
14950         return ret_ref;
14951 }
14952
14953 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14954         LDKDelayedPaymentOutputDescriptor o_conv;
14955         o_conv.inner = (void*)(o & (~1));
14956         o_conv.is_owned = (o & 1) || (o == 0);
14957         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14958         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14959         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14960         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14961         return (uint32_t)ret_conv;
14962 }
14963
14964 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14965         LDKDecodeError e_conv;
14966         e_conv.inner = (void*)(e & (~1));
14967         e_conv.is_owned = (e & 1) || (e == 0);
14968         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14969         e_conv = DecodeError_clone(&e_conv);
14970         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14971         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14972         return (uint32_t)ret_conv;
14973 }
14974
14975 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14976         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14977         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14978         return ret_conv;
14979 }
14980
14981 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14982         if ((_res & 1) != 0) return;
14983         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14984         CHECK_ACCESS(_res_ptr);
14985         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14986         FREE((void*)_res);
14987         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14988 }
14989
14990 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14991         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14992         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14993         return (uint32_t)ret_conv;
14994 }
14995 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14996         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14997         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14998         return ret_conv;
14999 }
15000
15001 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15002         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15003         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15004         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15005         return (uint32_t)ret_conv;
15006 }
15007
15008 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15009         LDKStaticPaymentOutputDescriptor o_conv;
15010         o_conv.inner = (void*)(o & (~1));
15011         o_conv.is_owned = (o & 1) || (o == 0);
15012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15013         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
15014         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15015         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
15016         return (uint32_t)ret_conv;
15017 }
15018
15019 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15020         LDKDecodeError e_conv;
15021         e_conv.inner = (void*)(e & (~1));
15022         e_conv.is_owned = (e & 1) || (e == 0);
15023         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15024         e_conv = DecodeError_clone(&e_conv);
15025         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15026         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
15027         return (uint32_t)ret_conv;
15028 }
15029
15030 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15031         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
15032         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15033         return ret_conv;
15034 }
15035
15036 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15037         if ((_res & 1) != 0) return;
15038         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15039         CHECK_ACCESS(_res_ptr);
15040         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15041         FREE((void*)_res);
15042         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15043 }
15044
15045 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15046         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15047         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15048         return (uint32_t)ret_conv;
15049 }
15050 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15051         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15052         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15053         return ret_conv;
15054 }
15055
15056 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15057         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15058         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15059         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15060         return (uint32_t)ret_conv;
15061 }
15062
15063 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15064         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15065         CHECK_ACCESS(o_ptr);
15066         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15067         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15068         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15069         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15070         return (uint32_t)ret_conv;
15071 }
15072
15073 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15074         LDKDecodeError e_conv;
15075         e_conv.inner = (void*)(e & (~1));
15076         e_conv.is_owned = (e & 1) || (e == 0);
15077         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15078         e_conv = DecodeError_clone(&e_conv);
15079         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15080         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15081         return (uint32_t)ret_conv;
15082 }
15083
15084 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15085         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15086         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15087         return ret_conv;
15088 }
15089
15090 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15091         if ((_res & 1) != 0) return;
15092         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15093         CHECK_ACCESS(_res_ptr);
15094         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15095         FREE((void*)_res);
15096         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15097 }
15098
15099 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15100         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15101         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15102         return (uint32_t)ret_conv;
15103 }
15104 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15105         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15106         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15107         return ret_conv;
15108 }
15109
15110 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15111         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15112         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15113         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15114         return (uint32_t)ret_conv;
15115 }
15116
15117 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
15118         LDKCVec_PaymentPreimageZ _res_constr;
15119         _res_constr.datalen = _res->arr_len;
15120         if (_res_constr.datalen > 0)
15121                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
15122         else
15123                 _res_constr.data = NULL;
15124         int8_tArray* _res_vals = (void*) _res->elems;
15125         for (size_t m = 0; m < _res_constr.datalen; m++) {
15126                 int8_tArray _res_conv_12 = _res_vals[m];
15127                 LDKThirtyTwoBytes _res_conv_12_ref;
15128                 CHECK(_res_conv_12->arr_len == 32);
15129                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
15130                 _res_constr.data[m] = _res_conv_12_ref;
15131         }
15132         FREE(_res);
15133         CVec_PaymentPreimageZ_free(_res_constr);
15134 }
15135
15136 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15137         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15138         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15139         return ((uint32_t)ret_conv);
15140 }
15141 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15142         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15143         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15144         return ret_conv;
15145 }
15146
15147 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15148         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15149         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15150         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15151         return ((uint32_t)ret_conv);
15152 }
15153
15154 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15155         LDKSignature a_ref;
15156         CHECK(a->arr_len == 64);
15157         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15158         LDKCVec_SignatureZ b_constr;
15159         b_constr.datalen = b->arr_len;
15160         if (b_constr.datalen > 0)
15161                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15162         else
15163                 b_constr.data = NULL;
15164         int8_tArray* b_vals = (void*) b->elems;
15165         for (size_t m = 0; m < b_constr.datalen; m++) {
15166                 int8_tArray b_conv_12 = b_vals[m];
15167                 LDKSignature b_conv_12_ref;
15168                 CHECK(b_conv_12->arr_len == 64);
15169                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15170                 b_constr.data[m] = b_conv_12_ref;
15171         }
15172         FREE(b);
15173         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15174         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15175         return ((uint32_t)ret_conv);
15176 }
15177
15178 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_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         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15183         FREE((void*)_res);
15184         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15185 }
15186
15187 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15188         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15189         CHECK_ACCESS(o_ptr);
15190         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15191         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15192         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15193         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15194         return (uint32_t)ret_conv;
15195 }
15196
15197 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15198         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15199         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15200         return (uint32_t)ret_conv;
15201 }
15202
15203 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15204         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15205         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15206         return ret_conv;
15207 }
15208
15209 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15210         if ((_res & 1) != 0) return;
15211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15212         CHECK_ACCESS(_res_ptr);
15213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15214         FREE((void*)_res);
15215         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15216 }
15217
15218 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15219         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15220         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15221         return (uint32_t)ret_conv;
15222 }
15223 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15224         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15225         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15226         return ret_conv;
15227 }
15228
15229 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15230         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15231         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15232         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15233         return (uint32_t)ret_conv;
15234 }
15235
15236 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15237         LDKSignature o_ref;
15238         CHECK(o->arr_len == 64);
15239         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15240         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15241         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15242         return (uint32_t)ret_conv;
15243 }
15244
15245 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15246         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15247         *ret_conv = CResult_SignatureNoneZ_err();
15248         return (uint32_t)ret_conv;
15249 }
15250
15251 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15252         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15253         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
15254         return ret_conv;
15255 }
15256
15257 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15258         if ((_res & 1) != 0) return;
15259         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15260         CHECK_ACCESS(_res_ptr);
15261         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15262         FREE((void*)_res);
15263         CResult_SignatureNoneZ_free(_res_conv);
15264 }
15265
15266 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15267         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15268         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15269         return (uint32_t)ret_conv;
15270 }
15271 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15272         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15273         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15274         return ret_conv;
15275 }
15276
15277 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15278         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15279         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15280         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15281         return (uint32_t)ret_conv;
15282 }
15283
15284 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
15285         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15286         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
15287         return ((uint32_t)ret_conv);
15288 }
15289 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
15290         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
15291         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
15292         return ret_conv;
15293 }
15294
15295 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
15296         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
15297         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15298         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
15299         return ((uint32_t)ret_conv);
15300 }
15301
15302 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
15303         LDKSignature a_ref;
15304         CHECK(a->arr_len == 64);
15305         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15306         LDKSignature b_ref;
15307         CHECK(b->arr_len == 64);
15308         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
15309         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15310         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
15311         return ((uint32_t)ret_conv);
15312 }
15313
15314 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
15315         if ((_res & 1) != 0) return;
15316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15317         CHECK_ACCESS(_res_ptr);
15318         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
15319         FREE((void*)_res);
15320         C2Tuple_SignatureSignatureZ_free(_res_conv);
15321 }
15322
15323 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
15324         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15325         CHECK_ACCESS(o_ptr);
15326         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
15327         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
15328         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15329         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
15330         return (uint32_t)ret_conv;
15331 }
15332
15333 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
15334         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15335         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
15336         return (uint32_t)ret_conv;
15337 }
15338
15339 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
15340         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
15341         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
15342         return ret_conv;
15343 }
15344
15345 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
15346         if ((_res & 1) != 0) return;
15347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15348         CHECK_ACCESS(_res_ptr);
15349         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
15350         FREE((void*)_res);
15351         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
15352 }
15353
15354 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
15355         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15356         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
15357         return (uint32_t)ret_conv;
15358 }
15359 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
15360         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
15361         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
15362         return ret_conv;
15363 }
15364
15365 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
15366         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
15367         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15368         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
15369         return (uint32_t)ret_conv;
15370 }
15371
15372 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
15373         LDKSecretKey o_ref;
15374         CHECK(o->arr_len == 32);
15375         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
15376         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15377         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
15378         return (uint32_t)ret_conv;
15379 }
15380
15381 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
15382         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15383         *ret_conv = CResult_SecretKeyNoneZ_err();
15384         return (uint32_t)ret_conv;
15385 }
15386
15387 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
15388         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
15389         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
15390         return ret_conv;
15391 }
15392
15393 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
15394         if ((_res & 1) != 0) return;
15395         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15396         CHECK_ACCESS(_res_ptr);
15397         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15398         FREE((void*)_res);
15399         CResult_SecretKeyNoneZ_free(_res_conv);
15400 }
15401
15402 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15403         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15404         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15405         return (uint32_t)ret_conv;
15406 }
15407 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
15408         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
15409         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15410         return ret_conv;
15411 }
15412
15413 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
15414         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
15415         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15416         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15417         return (uint32_t)ret_conv;
15418 }
15419
15420 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15421         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15422         CHECK_ACCESS(o_ptr);
15423         LDKSign o_conv = *(LDKSign*)(o_ptr);
15424         if (o_conv.free == LDKSign_JCalls_free) {
15425                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15426                 LDKSign_JCalls_cloned(&o_conv);
15427         }
15428         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15429         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15430         return (uint32_t)ret_conv;
15431 }
15432
15433 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15434         LDKDecodeError e_conv;
15435         e_conv.inner = (void*)(e & (~1));
15436         e_conv.is_owned = (e & 1) || (e == 0);
15437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15438         e_conv = DecodeError_clone(&e_conv);
15439         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15440         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15441         return (uint32_t)ret_conv;
15442 }
15443
15444 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15445         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15446         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15447         return ret_conv;
15448 }
15449
15450 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15451         if ((_res & 1) != 0) return;
15452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15453         CHECK_ACCESS(_res_ptr);
15454         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15455         FREE((void*)_res);
15456         CResult_SignDecodeErrorZ_free(_res_conv);
15457 }
15458
15459 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15460         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15461         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15462         return (uint32_t)ret_conv;
15463 }
15464 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15465         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15466         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15467         return ret_conv;
15468 }
15469
15470 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15471         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15472         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15473         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15474         return (uint32_t)ret_conv;
15475 }
15476
15477 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15478         LDKCVec_u5Z _res_constr;
15479         _res_constr.datalen = _res->arr_len;
15480         if (_res_constr.datalen > 0)
15481                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15482         else
15483                 _res_constr.data = NULL;
15484         int8_t* _res_vals = (void*) _res->elems;
15485         for (size_t h = 0; h < _res_constr.datalen; h++) {
15486                 int8_t _res_conv_7 = _res_vals[h];
15487                 
15488                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15489         }
15490         FREE(_res);
15491         CVec_u5Z_free(_res_constr);
15492 }
15493
15494 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15495         LDKRecoverableSignature o_ref;
15496         CHECK(o->arr_len == 68);
15497         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15498         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15499         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15500         return (uint32_t)ret_conv;
15501 }
15502
15503 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15504         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15505         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15506         return (uint32_t)ret_conv;
15507 }
15508
15509 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15510         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15511         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15512         return ret_conv;
15513 }
15514
15515 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15516         if ((_res & 1) != 0) return;
15517         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15518         CHECK_ACCESS(_res_ptr);
15519         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15520         FREE((void*)_res);
15521         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15522 }
15523
15524 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15525         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15526         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15527         return (uint32_t)ret_conv;
15528 }
15529 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15530         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15531         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15532         return ret_conv;
15533 }
15534
15535 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15536         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15537         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15538         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15539         return (uint32_t)ret_conv;
15540 }
15541
15542 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15543         LDKCVec_u8Z _res_ref;
15544         _res_ref.datalen = _res->arr_len;
15545         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15546         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15547         CVec_u8Z_free(_res_ref);
15548 }
15549
15550 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15551         LDKCVec_CVec_u8ZZ _res_constr;
15552         _res_constr.datalen = _res->arr_len;
15553         if (_res_constr.datalen > 0)
15554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15555         else
15556                 _res_constr.data = NULL;
15557         int8_tArray* _res_vals = (void*) _res->elems;
15558         for (size_t m = 0; m < _res_constr.datalen; m++) {
15559                 int8_tArray _res_conv_12 = _res_vals[m];
15560                 LDKCVec_u8Z _res_conv_12_ref;
15561                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15562                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15563                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15564                 _res_constr.data[m] = _res_conv_12_ref;
15565         }
15566         FREE(_res);
15567         CVec_CVec_u8ZZ_free(_res_constr);
15568 }
15569
15570 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15571         LDKCVec_CVec_u8ZZ o_constr;
15572         o_constr.datalen = o->arr_len;
15573         if (o_constr.datalen > 0)
15574                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15575         else
15576                 o_constr.data = NULL;
15577         int8_tArray* o_vals = (void*) o->elems;
15578         for (size_t m = 0; m < o_constr.datalen; m++) {
15579                 int8_tArray o_conv_12 = o_vals[m];
15580                 LDKCVec_u8Z o_conv_12_ref;
15581                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15582                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15583                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15584                 o_constr.data[m] = o_conv_12_ref;
15585         }
15586         FREE(o);
15587         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15588         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15589         return (uint32_t)ret_conv;
15590 }
15591
15592 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15593         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15594         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15595         return (uint32_t)ret_conv;
15596 }
15597
15598 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15599         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15600         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15601         return ret_conv;
15602 }
15603
15604 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15605         if ((_res & 1) != 0) return;
15606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15607         CHECK_ACCESS(_res_ptr);
15608         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15609         FREE((void*)_res);
15610         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15611 }
15612
15613 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15614         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15615         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15616         return (uint32_t)ret_conv;
15617 }
15618 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15619         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15620         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15621         return ret_conv;
15622 }
15623
15624 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15625         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15626         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15627         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15628         return (uint32_t)ret_conv;
15629 }
15630
15631 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15632         LDKInMemorySigner o_conv;
15633         o_conv.inner = (void*)(o & (~1));
15634         o_conv.is_owned = (o & 1) || (o == 0);
15635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15636         o_conv = InMemorySigner_clone(&o_conv);
15637         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15638         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15639         return (uint32_t)ret_conv;
15640 }
15641
15642 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15643         LDKDecodeError e_conv;
15644         e_conv.inner = (void*)(e & (~1));
15645         e_conv.is_owned = (e & 1) || (e == 0);
15646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15647         e_conv = DecodeError_clone(&e_conv);
15648         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15649         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15650         return (uint32_t)ret_conv;
15651 }
15652
15653 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15654         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15655         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15656         return ret_conv;
15657 }
15658
15659 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15660         if ((_res & 1) != 0) return;
15661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15662         CHECK_ACCESS(_res_ptr);
15663         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15664         FREE((void*)_res);
15665         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15666 }
15667
15668 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15669         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15670         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15671         return (uint32_t)ret_conv;
15672 }
15673 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15674         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15675         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15676         return ret_conv;
15677 }
15678
15679 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15680         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15681         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15682         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15683         return (uint32_t)ret_conv;
15684 }
15685
15686 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15687         LDKCVec_TxOutZ _res_constr;
15688         _res_constr.datalen = _res->arr_len;
15689         if (_res_constr.datalen > 0)
15690                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15691         else
15692                 _res_constr.data = NULL;
15693         uint32_t* _res_vals = _res->elems;
15694         for (size_t h = 0; h < _res_constr.datalen; h++) {
15695                 uint32_t _res_conv_7 = _res_vals[h];
15696                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15697                 CHECK_ACCESS(_res_conv_7_ptr);
15698                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15699                 FREE((void*)_res_conv_7);
15700                 _res_constr.data[h] = _res_conv_7_conv;
15701         }
15702         FREE(_res);
15703         CVec_TxOutZ_free(_res_constr);
15704 }
15705
15706 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15707         LDKTransaction o_ref;
15708         o_ref.datalen = o->arr_len;
15709         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15710         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15711         o_ref.data_is_owned = true;
15712         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15713         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15714         return (uint32_t)ret_conv;
15715 }
15716
15717 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15718         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15719         *ret_conv = CResult_TransactionNoneZ_err();
15720         return (uint32_t)ret_conv;
15721 }
15722
15723 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15724         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15725         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15726         return ret_conv;
15727 }
15728
15729 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15730         if ((_res & 1) != 0) return;
15731         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15732         CHECK_ACCESS(_res_ptr);
15733         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15734         FREE((void*)_res);
15735         CResult_TransactionNoneZ_free(_res_conv);
15736 }
15737
15738 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15739         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15740         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15741         return (uint32_t)ret_conv;
15742 }
15743 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15744         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15745         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15746         return ret_conv;
15747 }
15748
15749 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15750         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15751         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15752         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15753         return (uint32_t)ret_conv;
15754 }
15755
15756 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15757         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15758         *ret_copy = COption_u16Z_some(o);
15759         uint32_t ret_ref = (uintptr_t)ret_copy;
15760         return ret_ref;
15761 }
15762
15763 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15764         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15765         *ret_copy = COption_u16Z_none();
15766         uint32_t ret_ref = (uintptr_t)ret_copy;
15767         return ret_ref;
15768 }
15769
15770 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15771         if ((_res & 1) != 0) return;
15772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15773         CHECK_ACCESS(_res_ptr);
15774         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15775         FREE((void*)_res);
15776         COption_u16Z_free(_res_conv);
15777 }
15778
15779 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15780         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15781         *ret_copy = COption_u16Z_clone(arg);
15782 uint32_t ret_ref = (uintptr_t)ret_copy;
15783         return ret_ref;
15784 }
15785 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15786         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15787         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15788         return ret_conv;
15789 }
15790
15791 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15792         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15793         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15794         *ret_copy = COption_u16Z_clone(orig_conv);
15795         uint32_t ret_ref = (uintptr_t)ret_copy;
15796         return ret_ref;
15797 }
15798
15799 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15800         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15801         *ret_conv = CResult_NoneAPIErrorZ_ok();
15802         return (uint32_t)ret_conv;
15803 }
15804
15805 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15806         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15807         CHECK_ACCESS(e_ptr);
15808         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15809         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15810         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15811         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15812         return (uint32_t)ret_conv;
15813 }
15814
15815 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15816         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15817         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15818         return ret_conv;
15819 }
15820
15821 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15822         if ((_res & 1) != 0) return;
15823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15824         CHECK_ACCESS(_res_ptr);
15825         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15826         FREE((void*)_res);
15827         CResult_NoneAPIErrorZ_free(_res_conv);
15828 }
15829
15830 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15831         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15832         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15833         return (uint32_t)ret_conv;
15834 }
15835 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15836         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15837         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15838         return ret_conv;
15839 }
15840
15841 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15842         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15843         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15844         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15845         return (uint32_t)ret_conv;
15846 }
15847
15848 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15849         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15850         _res_constr.datalen = _res->arr_len;
15851         if (_res_constr.datalen > 0)
15852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15853         else
15854                 _res_constr.data = NULL;
15855         uint32_t* _res_vals = _res->elems;
15856         for (size_t w = 0; w < _res_constr.datalen; w++) {
15857                 uint32_t _res_conv_22 = _res_vals[w];
15858                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15859                 CHECK_ACCESS(_res_conv_22_ptr);
15860                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15861                 FREE((void*)_res_conv_22);
15862                 _res_constr.data[w] = _res_conv_22_conv;
15863         }
15864         FREE(_res);
15865         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15866 }
15867
15868 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15869         LDKCVec_APIErrorZ _res_constr;
15870         _res_constr.datalen = _res->arr_len;
15871         if (_res_constr.datalen > 0)
15872                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15873         else
15874                 _res_constr.data = NULL;
15875         uint32_t* _res_vals = _res->elems;
15876         for (size_t k = 0; k < _res_constr.datalen; k++) {
15877                 uint32_t _res_conv_10 = _res_vals[k];
15878                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15879                 CHECK_ACCESS(_res_conv_10_ptr);
15880                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15881                 FREE((void*)_res_conv_10);
15882                 _res_constr.data[k] = _res_conv_10_conv;
15883         }
15884         FREE(_res);
15885         CVec_APIErrorZ_free(_res_constr);
15886 }
15887
15888 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15889         LDKThirtyTwoBytes o_ref;
15890         CHECK(o->arr_len == 32);
15891         memcpy(o_ref.data, o->elems, 32); FREE(o);
15892         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15893         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15894         return (uint32_t)ret_conv;
15895 }
15896
15897 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15898         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15899         CHECK_ACCESS(e_ptr);
15900         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15901         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15902         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15903         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15904         return (uint32_t)ret_conv;
15905 }
15906
15907 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15908         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15909         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15910         return ret_conv;
15911 }
15912
15913 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15914         if ((_res & 1) != 0) return;
15915         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15916         CHECK_ACCESS(_res_ptr);
15917         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15918         FREE((void*)_res);
15919         CResult__u832APIErrorZ_free(_res_conv);
15920 }
15921
15922 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15923         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15924         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15925         return (uint32_t)ret_conv;
15926 }
15927 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15928         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15929         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15930         return ret_conv;
15931 }
15932
15933 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15934         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15935         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15936         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15937         return (uint32_t)ret_conv;
15938 }
15939
15940 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15941         LDKThirtyTwoBytes o_ref;
15942         CHECK(o->arr_len == 32);
15943         memcpy(o_ref.data, o->elems, 32); FREE(o);
15944         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15945         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15946         return (uint32_t)ret_conv;
15947 }
15948
15949 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15950         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15951         CHECK_ACCESS(e_ptr);
15952         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15953         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15954         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15955         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15956         return (uint32_t)ret_conv;
15957 }
15958
15959 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15960         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15961         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15962         return ret_conv;
15963 }
15964
15965 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15966         if ((_res & 1) != 0) return;
15967         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15968         CHECK_ACCESS(_res_ptr);
15969         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15970         FREE((void*)_res);
15971         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15972 }
15973
15974 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15975         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15976         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15977         return (uint32_t)ret_conv;
15978 }
15979 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15980         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15981         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15982         return ret_conv;
15983 }
15984
15985 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15986         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15987         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15988         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15989         return (uint32_t)ret_conv;
15990 }
15991
15992 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15993         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15994         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15995         return (uint32_t)ret_conv;
15996 }
15997
15998 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15999         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16000         CHECK_ACCESS(e_ptr);
16001         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16002         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16003         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16004         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
16005         return (uint32_t)ret_conv;
16006 }
16007
16008 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
16009         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
16010         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
16011         return ret_conv;
16012 }
16013
16014 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
16015         if ((_res & 1) != 0) return;
16016         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16017         CHECK_ACCESS(_res_ptr);
16018         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
16019         FREE((void*)_res);
16020         CResult_NonePaymentSendFailureZ_free(_res_conv);
16021 }
16022
16023 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
16024         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16025         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
16026         return (uint32_t)ret_conv;
16027 }
16028 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
16029         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
16030         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
16031         return ret_conv;
16032 }
16033
16034 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
16035         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
16036         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16037         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
16038         return (uint32_t)ret_conv;
16039 }
16040
16041 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
16042         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16043         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
16044         return ((uint32_t)ret_conv);
16045 }
16046 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
16047         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
16048         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
16049         return ret_conv;
16050 }
16051
16052 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
16053         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
16054         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16055         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
16056         return ((uint32_t)ret_conv);
16057 }
16058
16059 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
16060         LDKThirtyTwoBytes a_ref;
16061         CHECK(a->arr_len == 32);
16062         memcpy(a_ref.data, a->elems, 32); FREE(a);
16063         LDKThirtyTwoBytes b_ref;
16064         CHECK(b->arr_len == 32);
16065         memcpy(b_ref.data, b->elems, 32); FREE(b);
16066         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16067         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
16068         return ((uint32_t)ret_conv);
16069 }
16070
16071 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
16072         if ((_res & 1) != 0) return;
16073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16074         CHECK_ACCESS(_res_ptr);
16075         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
16076         FREE((void*)_res);
16077         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
16078 }
16079
16080 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
16081         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16082         CHECK_ACCESS(o_ptr);
16083         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
16084         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
16085         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16086         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
16087         return (uint32_t)ret_conv;
16088 }
16089
16090 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
16091         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16092         CHECK_ACCESS(e_ptr);
16093         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16094         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16095         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16096         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
16097         return (uint32_t)ret_conv;
16098 }
16099
16100 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
16101         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
16102         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
16103         return ret_conv;
16104 }
16105
16106 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
16107         if ((_res & 1) != 0) return;
16108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16109         CHECK_ACCESS(_res_ptr);
16110         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
16111         FREE((void*)_res);
16112         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
16113 }
16114
16115 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
16116         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16117         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
16118         return (uint32_t)ret_conv;
16119 }
16120 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
16121         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
16122         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
16123         return ret_conv;
16124 }
16125
16126 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
16127         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
16128         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16129         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
16130         return (uint32_t)ret_conv;
16131 }
16132
16133 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16134         LDKCVec_ThirtyTwoBytesZ _res_constr;
16135         _res_constr.datalen = _res->arr_len;
16136         if (_res_constr.datalen > 0)
16137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16138         else
16139                 _res_constr.data = NULL;
16140         int8_tArray* _res_vals = (void*) _res->elems;
16141         for (size_t m = 0; m < _res_constr.datalen; m++) {
16142                 int8_tArray _res_conv_12 = _res_vals[m];
16143                 LDKThirtyTwoBytes _res_conv_12_ref;
16144                 CHECK(_res_conv_12->arr_len == 32);
16145                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
16146                 _res_constr.data[m] = _res_conv_12_ref;
16147         }
16148         FREE(_res);
16149         CVec_ThirtyTwoBytesZ_free(_res_constr);
16150 }
16151
16152 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
16153         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16154         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
16155         return ((uint32_t)ret_conv);
16156 }
16157 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
16158         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
16159         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
16160         return ret_conv;
16161 }
16162
16163 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
16164         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
16165         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16166         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
16167         return ((uint32_t)ret_conv);
16168 }
16169
16170 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
16171         LDKThirtyTwoBytes a_ref;
16172         CHECK(a->arr_len == 32);
16173         memcpy(a_ref.data, a->elems, 32); FREE(a);
16174         LDKThirtyTwoBytes b_ref;
16175         CHECK(b->arr_len == 32);
16176         memcpy(b_ref.data, b->elems, 32); FREE(b);
16177         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16178         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16179         return ((uint32_t)ret_conv);
16180 }
16181
16182 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
16183         if ((_res & 1) != 0) return;
16184         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16185         CHECK_ACCESS(_res_ptr);
16186         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16187         FREE((void*)_res);
16188         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16189 }
16190
16191 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16192         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16193         CHECK_ACCESS(o_ptr);
16194         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16195         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16196         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16197         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16198         return (uint32_t)ret_conv;
16199 }
16200
16201 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16202         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16203         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16204         return (uint32_t)ret_conv;
16205 }
16206
16207 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16208         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16209         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16210         return ret_conv;
16211 }
16212
16213 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16214         if ((_res & 1) != 0) return;
16215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16216         CHECK_ACCESS(_res_ptr);
16217         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16218         FREE((void*)_res);
16219         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16220 }
16221
16222 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16223         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16224         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16225         return (uint32_t)ret_conv;
16226 }
16227 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16228         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16229         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16230         return ret_conv;
16231 }
16232
16233 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16234         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16235         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16236         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16237         return (uint32_t)ret_conv;
16238 }
16239
16240 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16241         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16242         CHECK_ACCESS(o_ptr);
16243         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16244         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16245         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16246         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16247         return (uint32_t)ret_conv;
16248 }
16249
16250 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16251         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16252         CHECK_ACCESS(e_ptr);
16253         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16254         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16255         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16256         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16257         return (uint32_t)ret_conv;
16258 }
16259
16260 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16261         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16262         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16263         return ret_conv;
16264 }
16265
16266 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16267         if ((_res & 1) != 0) return;
16268         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16269         CHECK_ACCESS(_res_ptr);
16270         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16271         FREE((void*)_res);
16272         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16273 }
16274
16275 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16276         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16277         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16278         return (uint32_t)ret_conv;
16279 }
16280 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16281         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16282         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16283         return ret_conv;
16284 }
16285
16286 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16287         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16288         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16289         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16290         return (uint32_t)ret_conv;
16291 }
16292
16293 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16294         LDKThirtyTwoBytes o_ref;
16295         CHECK(o->arr_len == 32);
16296         memcpy(o_ref.data, o->elems, 32); FREE(o);
16297         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16298         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16299         return (uint32_t)ret_conv;
16300 }
16301
16302 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16303         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16304         *ret_conv = CResult_PaymentSecretNoneZ_err();
16305         return (uint32_t)ret_conv;
16306 }
16307
16308 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16309         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16310         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16311         return ret_conv;
16312 }
16313
16314 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16315         if ((_res & 1) != 0) return;
16316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16317         CHECK_ACCESS(_res_ptr);
16318         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16319         FREE((void*)_res);
16320         CResult_PaymentSecretNoneZ_free(_res_conv);
16321 }
16322
16323 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16324         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16325         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16326         return (uint32_t)ret_conv;
16327 }
16328 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16329         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16330         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16331         return ret_conv;
16332 }
16333
16334 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16335         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16336         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16337         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16338         return (uint32_t)ret_conv;
16339 }
16340
16341 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16342         LDKThirtyTwoBytes o_ref;
16343         CHECK(o->arr_len == 32);
16344         memcpy(o_ref.data, o->elems, 32); FREE(o);
16345         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16346         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16347         return (uint32_t)ret_conv;
16348 }
16349
16350 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16351         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16352         CHECK_ACCESS(e_ptr);
16353         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16354         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16355         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16356         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16357         return (uint32_t)ret_conv;
16358 }
16359
16360 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16361         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16362         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16363         return ret_conv;
16364 }
16365
16366 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16367         if ((_res & 1) != 0) return;
16368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16369         CHECK_ACCESS(_res_ptr);
16370         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16371         FREE((void*)_res);
16372         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16373 }
16374
16375 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16376         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16377         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16378         return (uint32_t)ret_conv;
16379 }
16380 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16381         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16382         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16383         return ret_conv;
16384 }
16385
16386 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16387         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16388         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16389         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16390         return (uint32_t)ret_conv;
16391 }
16392
16393 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16394         LDKThirtyTwoBytes o_ref;
16395         CHECK(o->arr_len == 32);
16396         memcpy(o_ref.data, o->elems, 32); FREE(o);
16397         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16398         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16399         return (uint32_t)ret_conv;
16400 }
16401
16402 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16403         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16404         CHECK_ACCESS(e_ptr);
16405         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16406         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16407         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16408         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16409         return (uint32_t)ret_conv;
16410 }
16411
16412 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16413         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16414         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16415         return ret_conv;
16416 }
16417
16418 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16419         if ((_res & 1) != 0) return;
16420         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16421         CHECK_ACCESS(_res_ptr);
16422         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16423         FREE((void*)_res);
16424         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16425 }
16426
16427 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16428         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16429         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16430         return (uint32_t)ret_conv;
16431 }
16432 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16433         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16434         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16435         return ret_conv;
16436 }
16437
16438 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16439         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16440         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16441         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16442         return (uint32_t)ret_conv;
16443 }
16444
16445 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
16446         LDKCounterpartyForwardingInfo o_conv;
16447         o_conv.inner = (void*)(o & (~1));
16448         o_conv.is_owned = (o & 1) || (o == 0);
16449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16450         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16451         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16452         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16453         return (uint32_t)ret_conv;
16454 }
16455
16456 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
16457         LDKDecodeError e_conv;
16458         e_conv.inner = (void*)(e & (~1));
16459         e_conv.is_owned = (e & 1) || (e == 0);
16460         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16461         e_conv = DecodeError_clone(&e_conv);
16462         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16463         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16464         return (uint32_t)ret_conv;
16465 }
16466
16467 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
16468         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
16469         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16470         return ret_conv;
16471 }
16472
16473 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
16474         if ((_res & 1) != 0) return;
16475         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16476         CHECK_ACCESS(_res_ptr);
16477         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16478         FREE((void*)_res);
16479         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16480 }
16481
16482 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16483         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16484         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16485         return (uint32_t)ret_conv;
16486 }
16487 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16488         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
16489         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16490         return ret_conv;
16491 }
16492
16493 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
16494         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
16495         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16496         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16497         return (uint32_t)ret_conv;
16498 }
16499
16500 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
16501         LDKChannelCounterparty o_conv;
16502         o_conv.inner = (void*)(o & (~1));
16503         o_conv.is_owned = (o & 1) || (o == 0);
16504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16505         o_conv = ChannelCounterparty_clone(&o_conv);
16506         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16507         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16508         return (uint32_t)ret_conv;
16509 }
16510
16511 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
16512         LDKDecodeError e_conv;
16513         e_conv.inner = (void*)(e & (~1));
16514         e_conv.is_owned = (e & 1) || (e == 0);
16515         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16516         e_conv = DecodeError_clone(&e_conv);
16517         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16518         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16519         return (uint32_t)ret_conv;
16520 }
16521
16522 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
16523         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
16524         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16525         return ret_conv;
16526 }
16527
16528 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
16529         if ((_res & 1) != 0) return;
16530         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16531         CHECK_ACCESS(_res_ptr);
16532         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16533         FREE((void*)_res);
16534         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16535 }
16536
16537 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16538         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16539         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16540         return (uint32_t)ret_conv;
16541 }
16542 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
16543         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
16544         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16545         return ret_conv;
16546 }
16547
16548 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
16549         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
16550         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16551         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16552         return (uint32_t)ret_conv;
16553 }
16554
16555 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
16556         LDKChannelDetails o_conv;
16557         o_conv.inner = (void*)(o & (~1));
16558         o_conv.is_owned = (o & 1) || (o == 0);
16559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16560         o_conv = ChannelDetails_clone(&o_conv);
16561         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16562         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16563         return (uint32_t)ret_conv;
16564 }
16565
16566 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
16567         LDKDecodeError e_conv;
16568         e_conv.inner = (void*)(e & (~1));
16569         e_conv.is_owned = (e & 1) || (e == 0);
16570         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16571         e_conv = DecodeError_clone(&e_conv);
16572         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16573         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16574         return (uint32_t)ret_conv;
16575 }
16576
16577 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
16578         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
16579         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16580         return ret_conv;
16581 }
16582
16583 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
16584         if ((_res & 1) != 0) return;
16585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16586         CHECK_ACCESS(_res_ptr);
16587         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16588         FREE((void*)_res);
16589         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16590 }
16591
16592 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16593         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16594         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16595         return (uint32_t)ret_conv;
16596 }
16597 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
16598         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
16599         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16600         return ret_conv;
16601 }
16602
16603 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
16604         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
16605         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16606         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16607         return (uint32_t)ret_conv;
16608 }
16609
16610 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
16611         LDKPhantomRouteHints o_conv;
16612         o_conv.inner = (void*)(o & (~1));
16613         o_conv.is_owned = (o & 1) || (o == 0);
16614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16615         o_conv = PhantomRouteHints_clone(&o_conv);
16616         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16617         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16618         return (uint32_t)ret_conv;
16619 }
16620
16621 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
16622         LDKDecodeError e_conv;
16623         e_conv.inner = (void*)(e & (~1));
16624         e_conv.is_owned = (e & 1) || (e == 0);
16625         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16626         e_conv = DecodeError_clone(&e_conv);
16627         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16628         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16629         return (uint32_t)ret_conv;
16630 }
16631
16632 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
16633         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
16634         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16635         return ret_conv;
16636 }
16637
16638 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
16639         if ((_res & 1) != 0) return;
16640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16641         CHECK_ACCESS(_res_ptr);
16642         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16643         FREE((void*)_res);
16644         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16645 }
16646
16647 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16648         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16649         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16650         return (uint32_t)ret_conv;
16651 }
16652 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
16653         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
16654         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16655         return ret_conv;
16656 }
16657
16658 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
16659         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
16660         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16661         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16662         return (uint32_t)ret_conv;
16663 }
16664
16665 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16666         LDKCVec_ChannelMonitorZ _res_constr;
16667         _res_constr.datalen = _res->arr_len;
16668         if (_res_constr.datalen > 0)
16669                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16670         else
16671                 _res_constr.data = NULL;
16672         uint32_t* _res_vals = _res->elems;
16673         for (size_t q = 0; q < _res_constr.datalen; q++) {
16674                 uint32_t _res_conv_16 = _res_vals[q];
16675                 LDKChannelMonitor _res_conv_16_conv;
16676                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16677                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16679                 _res_constr.data[q] = _res_conv_16_conv;
16680         }
16681         FREE(_res);
16682         CVec_ChannelMonitorZ_free(_res_constr);
16683 }
16684
16685 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16686         LDKThirtyTwoBytes a_ref;
16687         CHECK(a->arr_len == 32);
16688         memcpy(a_ref.data, a->elems, 32); FREE(a);
16689         LDKChannelManager b_conv;
16690         b_conv.inner = (void*)(b & (~1));
16691         b_conv.is_owned = (b & 1) || (b == 0);
16692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16693         // WARNING: we need a move here but no clone is available for LDKChannelManager
16694         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16695         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16696         return ((uint32_t)ret_conv);
16697 }
16698
16699 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16700         if ((_res & 1) != 0) return;
16701         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16702         CHECK_ACCESS(_res_ptr);
16703         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16704         FREE((void*)_res);
16705         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16706 }
16707
16708 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16709         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16710         CHECK_ACCESS(o_ptr);
16711         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16712         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16713         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16714         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16715         return (uint32_t)ret_conv;
16716 }
16717
16718 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16719         LDKDecodeError e_conv;
16720         e_conv.inner = (void*)(e & (~1));
16721         e_conv.is_owned = (e & 1) || (e == 0);
16722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16723         e_conv = DecodeError_clone(&e_conv);
16724         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16725         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16726         return (uint32_t)ret_conv;
16727 }
16728
16729 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16730         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16731         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16732         return ret_conv;
16733 }
16734
16735 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16736         if ((_res & 1) != 0) return;
16737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16738         CHECK_ACCESS(_res_ptr);
16739         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16740         FREE((void*)_res);
16741         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16742 }
16743
16744 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16745         LDKChannelConfig o_conv;
16746         o_conv.inner = (void*)(o & (~1));
16747         o_conv.is_owned = (o & 1) || (o == 0);
16748         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16749         o_conv = ChannelConfig_clone(&o_conv);
16750         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16751         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16752         return (uint32_t)ret_conv;
16753 }
16754
16755 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16756         LDKDecodeError e_conv;
16757         e_conv.inner = (void*)(e & (~1));
16758         e_conv.is_owned = (e & 1) || (e == 0);
16759         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16760         e_conv = DecodeError_clone(&e_conv);
16761         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16762         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16763         return (uint32_t)ret_conv;
16764 }
16765
16766 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16767         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16768         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16769         return ret_conv;
16770 }
16771
16772 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16773         if ((_res & 1) != 0) return;
16774         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16775         CHECK_ACCESS(_res_ptr);
16776         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16777         FREE((void*)_res);
16778         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16779 }
16780
16781 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16782         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16783         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16784         return (uint32_t)ret_conv;
16785 }
16786 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16787         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16788         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16789         return ret_conv;
16790 }
16791
16792 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16793         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16794         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16795         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16796         return (uint32_t)ret_conv;
16797 }
16798
16799 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16800         LDKOutPoint o_conv;
16801         o_conv.inner = (void*)(o & (~1));
16802         o_conv.is_owned = (o & 1) || (o == 0);
16803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16804         o_conv = OutPoint_clone(&o_conv);
16805         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16806         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16807         return (uint32_t)ret_conv;
16808 }
16809
16810 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16811         LDKDecodeError e_conv;
16812         e_conv.inner = (void*)(e & (~1));
16813         e_conv.is_owned = (e & 1) || (e == 0);
16814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16815         e_conv = DecodeError_clone(&e_conv);
16816         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16817         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16818         return (uint32_t)ret_conv;
16819 }
16820
16821 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16822         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16823         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16824         return ret_conv;
16825 }
16826
16827 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16828         if ((_res & 1) != 0) return;
16829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16830         CHECK_ACCESS(_res_ptr);
16831         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16832         FREE((void*)_res);
16833         CResult_OutPointDecodeErrorZ_free(_res_conv);
16834 }
16835
16836 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16837         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16838         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16839         return (uint32_t)ret_conv;
16840 }
16841 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16842         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16843         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16844         return ret_conv;
16845 }
16846
16847 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16848         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16849         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16850         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16851         return (uint32_t)ret_conv;
16852 }
16853
16854 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16855         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16856         CHECK_ACCESS(o_ptr);
16857         LDKType o_conv = *(LDKType*)(o_ptr);
16858         if (o_conv.free == LDKType_JCalls_free) {
16859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16860                 LDKType_JCalls_cloned(&o_conv);
16861         }
16862         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16863         *ret_copy = COption_TypeZ_some(o_conv);
16864         uint32_t ret_ref = (uintptr_t)ret_copy;
16865         return ret_ref;
16866 }
16867
16868 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16869         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16870         *ret_copy = COption_TypeZ_none();
16871         uint32_t ret_ref = (uintptr_t)ret_copy;
16872         return ret_ref;
16873 }
16874
16875 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16876         if ((_res & 1) != 0) return;
16877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16878         CHECK_ACCESS(_res_ptr);
16879         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16880         FREE((void*)_res);
16881         COption_TypeZ_free(_res_conv);
16882 }
16883
16884 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16885         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16886         *ret_copy = COption_TypeZ_clone(arg);
16887 uint32_t ret_ref = (uintptr_t)ret_copy;
16888         return ret_ref;
16889 }
16890 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16891         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16892         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16893         return ret_conv;
16894 }
16895
16896 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16897         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16898         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16899         *ret_copy = COption_TypeZ_clone(orig_conv);
16900         uint32_t ret_ref = (uintptr_t)ret_copy;
16901         return ret_ref;
16902 }
16903
16904 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16905         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16906         CHECK_ACCESS(o_ptr);
16907         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16908         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16909         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16910         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16911         return (uint32_t)ret_conv;
16912 }
16913
16914 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16915         LDKDecodeError e_conv;
16916         e_conv.inner = (void*)(e & (~1));
16917         e_conv.is_owned = (e & 1) || (e == 0);
16918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16919         e_conv = DecodeError_clone(&e_conv);
16920         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16921         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16922         return (uint32_t)ret_conv;
16923 }
16924
16925 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16926         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16927         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16928         return ret_conv;
16929 }
16930
16931 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16932         if ((_res & 1) != 0) return;
16933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16934         CHECK_ACCESS(_res_ptr);
16935         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16936         FREE((void*)_res);
16937         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16938 }
16939
16940 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16941         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16942         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16943         return (uint32_t)ret_conv;
16944 }
16945 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16946         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16947         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16948         return ret_conv;
16949 }
16950
16951 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16952         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16953         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16954         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16955         return (uint32_t)ret_conv;
16956 }
16957
16958 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16959         LDKThirtyTwoBytes o_ref;
16960         CHECK(o->arr_len == 32);
16961         memcpy(o_ref.data, o->elems, 32); FREE(o);
16962         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16963         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16964         return (uint32_t)ret_conv;
16965 }
16966
16967 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16968         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16969         CHECK_ACCESS(e_ptr);
16970         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16971         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16972         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16973         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16974         return (uint32_t)ret_conv;
16975 }
16976
16977 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16978         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16979         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16980         return ret_conv;
16981 }
16982
16983 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16984         if ((_res & 1) != 0) return;
16985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16986         CHECK_ACCESS(_res_ptr);
16987         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16988         FREE((void*)_res);
16989         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16990 }
16991
16992 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16993         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16994         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16995         return (uint32_t)ret_conv;
16996 }
16997 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
16998         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
16999         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
17000         return ret_conv;
17001 }
17002
17003 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
17004         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
17005         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17006         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
17007         return (uint32_t)ret_conv;
17008 }
17009
17010 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
17011         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
17012         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17013         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
17014         return (uint32_t)ret_conv;
17015 }
17016
17017 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
17018         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17019         CHECK_ACCESS(e_ptr);
17020         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17021         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17022         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17023         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
17024         return (uint32_t)ret_conv;
17025 }
17026
17027 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
17028         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
17029         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
17030         return ret_conv;
17031 }
17032
17033 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
17034         if ((_res & 1) != 0) return;
17035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17036         CHECK_ACCESS(_res_ptr);
17037         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
17038         FREE((void*)_res);
17039         CResult_SiPrefixParseErrorZ_free(_res_conv);
17040 }
17041
17042 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
17043         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17044         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
17045         return (uint32_t)ret_conv;
17046 }
17047 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
17048         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
17049         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
17050         return ret_conv;
17051 }
17052
17053 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
17054         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
17055         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17056         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
17057         return (uint32_t)ret_conv;
17058 }
17059
17060 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
17061         LDKInvoice o_conv;
17062         o_conv.inner = (void*)(o & (~1));
17063         o_conv.is_owned = (o & 1) || (o == 0);
17064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17065         o_conv = Invoice_clone(&o_conv);
17066         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17067         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
17068         return (uint32_t)ret_conv;
17069 }
17070
17071 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
17072         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17073         CHECK_ACCESS(e_ptr);
17074         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
17075         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
17076         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17077         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
17078         return (uint32_t)ret_conv;
17079 }
17080
17081 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
17082         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
17083         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
17084         return ret_conv;
17085 }
17086
17087 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
17088         if ((_res & 1) != 0) return;
17089         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17090         CHECK_ACCESS(_res_ptr);
17091         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
17092         FREE((void*)_res);
17093         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
17094 }
17095
17096 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
17097         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17098         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
17099         return (uint32_t)ret_conv;
17100 }
17101 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
17102         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
17103         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
17104         return ret_conv;
17105 }
17106
17107 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
17108         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
17109         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17110         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
17111         return (uint32_t)ret_conv;
17112 }
17113
17114 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
17115         LDKSignedRawInvoice o_conv;
17116         o_conv.inner = (void*)(o & (~1));
17117         o_conv.is_owned = (o & 1) || (o == 0);
17118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17119         o_conv = SignedRawInvoice_clone(&o_conv);
17120         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17121         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
17122         return (uint32_t)ret_conv;
17123 }
17124
17125 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
17126         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17127         CHECK_ACCESS(e_ptr);
17128         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17129         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17130         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17131         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
17132         return (uint32_t)ret_conv;
17133 }
17134
17135 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
17136         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
17137         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
17138         return ret_conv;
17139 }
17140
17141 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
17142         if ((_res & 1) != 0) return;
17143         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17144         CHECK_ACCESS(_res_ptr);
17145         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
17146         FREE((void*)_res);
17147         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
17148 }
17149
17150 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
17151         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17152         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
17153         return (uint32_t)ret_conv;
17154 }
17155 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
17156         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
17157         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
17158         return ret_conv;
17159 }
17160
17161 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
17162         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
17163         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17164         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
17165         return (uint32_t)ret_conv;
17166 }
17167
17168 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
17169         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17170         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
17171         return ((uint32_t)ret_conv);
17172 }
17173 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
17174         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
17175         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
17176         return ret_conv;
17177 }
17178
17179 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
17180         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
17181         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17182         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
17183         return ((uint32_t)ret_conv);
17184 }
17185
17186 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
17187         LDKRawInvoice a_conv;
17188         a_conv.inner = (void*)(a & (~1));
17189         a_conv.is_owned = (a & 1) || (a == 0);
17190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17191         a_conv = RawInvoice_clone(&a_conv);
17192         LDKThirtyTwoBytes b_ref;
17193         CHECK(b->arr_len == 32);
17194         memcpy(b_ref.data, b->elems, 32); FREE(b);
17195         LDKInvoiceSignature c_conv;
17196         c_conv.inner = (void*)(c & (~1));
17197         c_conv.is_owned = (c & 1) || (c == 0);
17198         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17199         c_conv = InvoiceSignature_clone(&c_conv);
17200         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17201         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
17202         return ((uint32_t)ret_conv);
17203 }
17204
17205 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
17206         if ((_res & 1) != 0) return;
17207         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17208         CHECK_ACCESS(_res_ptr);
17209         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
17210         FREE((void*)_res);
17211         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
17212 }
17213
17214 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
17215         LDKPayeePubKey o_conv;
17216         o_conv.inner = (void*)(o & (~1));
17217         o_conv.is_owned = (o & 1) || (o == 0);
17218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17219         o_conv = PayeePubKey_clone(&o_conv);
17220         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17221         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
17222         return (uint32_t)ret_conv;
17223 }
17224
17225 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
17226         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17227         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17228         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
17229         return (uint32_t)ret_conv;
17230 }
17231
17232 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
17233         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
17234         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
17235         return ret_conv;
17236 }
17237
17238 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
17239         if ((_res & 1) != 0) return;
17240         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17241         CHECK_ACCESS(_res_ptr);
17242         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
17243         FREE((void*)_res);
17244         CResult_PayeePubKeyErrorZ_free(_res_conv);
17245 }
17246
17247 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
17248         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17249         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
17250         return (uint32_t)ret_conv;
17251 }
17252 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
17253         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
17254         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
17255         return ret_conv;
17256 }
17257
17258 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
17259         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
17260         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17261         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
17262         return (uint32_t)ret_conv;
17263 }
17264
17265 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
17266         LDKCVec_PrivateRouteZ _res_constr;
17267         _res_constr.datalen = _res->arr_len;
17268         if (_res_constr.datalen > 0)
17269                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
17270         else
17271                 _res_constr.data = NULL;
17272         uint32_t* _res_vals = _res->elems;
17273         for (size_t o = 0; o < _res_constr.datalen; o++) {
17274                 uint32_t _res_conv_14 = _res_vals[o];
17275                 LDKPrivateRoute _res_conv_14_conv;
17276                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
17277                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
17278                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17279                 _res_constr.data[o] = _res_conv_14_conv;
17280         }
17281         FREE(_res);
17282         CVec_PrivateRouteZ_free(_res_constr);
17283 }
17284
17285 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
17286         LDKPositiveTimestamp 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 = PositiveTimestamp_clone(&o_conv);
17291         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17292         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
17293         return (uint32_t)ret_conv;
17294 }
17295
17296 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
17297         LDKCreationError e_conv = LDKCreationError_from_js(e);
17298         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17299         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
17300         return (uint32_t)ret_conv;
17301 }
17302
17303 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
17304         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
17305         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
17306         return ret_conv;
17307 }
17308
17309 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
17310         if ((_res & 1) != 0) return;
17311         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17312         CHECK_ACCESS(_res_ptr);
17313         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
17314         FREE((void*)_res);
17315         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
17316 }
17317
17318 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
17319         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17320         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
17321         return (uint32_t)ret_conv;
17322 }
17323 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
17324         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
17325         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
17326         return ret_conv;
17327 }
17328
17329 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
17330         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
17331         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17332         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
17333         return (uint32_t)ret_conv;
17334 }
17335
17336 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
17337         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17338         *ret_conv = CResult_NoneSemanticErrorZ_ok();
17339         return (uint32_t)ret_conv;
17340 }
17341
17342 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
17343         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17344         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17345         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
17346         return (uint32_t)ret_conv;
17347 }
17348
17349 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
17350         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
17351         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
17352         return ret_conv;
17353 }
17354
17355 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
17356         if ((_res & 1) != 0) return;
17357         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17358         CHECK_ACCESS(_res_ptr);
17359         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
17360         FREE((void*)_res);
17361         CResult_NoneSemanticErrorZ_free(_res_conv);
17362 }
17363
17364 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
17365         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17366         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
17367         return (uint32_t)ret_conv;
17368 }
17369 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
17370         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
17371         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
17372         return ret_conv;
17373 }
17374
17375 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
17376         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
17377         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17378         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
17379         return (uint32_t)ret_conv;
17380 }
17381
17382 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
17383         LDKInvoice o_conv;
17384         o_conv.inner = (void*)(o & (~1));
17385         o_conv.is_owned = (o & 1) || (o == 0);
17386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17387         o_conv = Invoice_clone(&o_conv);
17388         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17389         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
17390         return (uint32_t)ret_conv;
17391 }
17392
17393 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
17394         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17395         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17396         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17397         return (uint32_t)ret_conv;
17398 }
17399
17400 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
17401         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17402         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17403         return ret_conv;
17404 }
17405
17406 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
17407         if ((_res & 1) != 0) return;
17408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17409         CHECK_ACCESS(_res_ptr);
17410         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17411         FREE((void*)_res);
17412         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17413 }
17414
17415 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17416         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17417         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17418         return (uint32_t)ret_conv;
17419 }
17420 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
17421         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17422         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17423         return ret_conv;
17424 }
17425
17426 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
17427         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17428         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17429         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17430         return (uint32_t)ret_conv;
17431 }
17432
17433 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
17434         LDKDescription o_conv;
17435         o_conv.inner = (void*)(o & (~1));
17436         o_conv.is_owned = (o & 1) || (o == 0);
17437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17438         o_conv = Description_clone(&o_conv);
17439         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17440         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17441         return (uint32_t)ret_conv;
17442 }
17443
17444 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17445         LDKCreationError e_conv = LDKCreationError_from_js(e);
17446         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17447         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17448         return (uint32_t)ret_conv;
17449 }
17450
17451 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
17452         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17453         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17454         return ret_conv;
17455 }
17456
17457 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
17458         if ((_res & 1) != 0) return;
17459         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17460         CHECK_ACCESS(_res_ptr);
17461         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17462         FREE((void*)_res);
17463         CResult_DescriptionCreationErrorZ_free(_res_conv);
17464 }
17465
17466 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17467         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17468         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17469         return (uint32_t)ret_conv;
17470 }
17471 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
17472         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17473         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17474         return ret_conv;
17475 }
17476
17477 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
17478         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17479         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17480         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17481         return (uint32_t)ret_conv;
17482 }
17483
17484 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
17485         LDKPrivateRoute o_conv;
17486         o_conv.inner = (void*)(o & (~1));
17487         o_conv.is_owned = (o & 1) || (o == 0);
17488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17489         o_conv = PrivateRoute_clone(&o_conv);
17490         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17491         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17492         return (uint32_t)ret_conv;
17493 }
17494
17495 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17496         LDKCreationError e_conv = LDKCreationError_from_js(e);
17497         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17498         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17499         return (uint32_t)ret_conv;
17500 }
17501
17502 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
17503         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17504         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17505         return ret_conv;
17506 }
17507
17508 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
17509         if ((_res & 1) != 0) return;
17510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17511         CHECK_ACCESS(_res_ptr);
17512         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17513         FREE((void*)_res);
17514         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17515 }
17516
17517 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17518         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17519         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17520         return (uint32_t)ret_conv;
17521 }
17522 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
17523         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17524         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17525         return ret_conv;
17526 }
17527
17528 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
17529         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17530         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17531         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17532         return (uint32_t)ret_conv;
17533 }
17534
17535 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17536         LDKStr o_conv = str_ref_to_owned_c(o);
17537         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17538         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17539         return (uint32_t)ret_conv;
17540 }
17541
17542 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17543         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17544         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17545         *ret_conv = CResult_StringErrorZ_err(e_conv);
17546         return (uint32_t)ret_conv;
17547 }
17548
17549 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
17550         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17551         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17552         return ret_conv;
17553 }
17554
17555 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
17556         if ((_res & 1) != 0) return;
17557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17558         CHECK_ACCESS(_res_ptr);
17559         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17560         FREE((void*)_res);
17561         CResult_StringErrorZ_free(_res_conv);
17562 }
17563
17564 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17565         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17566         *ret_conv = CResult_StringErrorZ_clone(arg);
17567         return (uint32_t)ret_conv;
17568 }
17569 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
17570         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
17571         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17572         return ret_conv;
17573 }
17574
17575 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
17576         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
17577         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17578         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17579         return (uint32_t)ret_conv;
17580 }
17581
17582 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
17583         LDKChannelMonitorUpdate o_conv;
17584         o_conv.inner = (void*)(o & (~1));
17585         o_conv.is_owned = (o & 1) || (o == 0);
17586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17587         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17588         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17589         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17590         return (uint32_t)ret_conv;
17591 }
17592
17593 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
17594         LDKDecodeError e_conv;
17595         e_conv.inner = (void*)(e & (~1));
17596         e_conv.is_owned = (e & 1) || (e == 0);
17597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17598         e_conv = DecodeError_clone(&e_conv);
17599         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17600         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17601         return (uint32_t)ret_conv;
17602 }
17603
17604 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
17605         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17606         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17607         return ret_conv;
17608 }
17609
17610 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
17611         if ((_res & 1) != 0) return;
17612         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17613         CHECK_ACCESS(_res_ptr);
17614         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17615         FREE((void*)_res);
17616         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17617 }
17618
17619 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17620         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17621         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17622         return (uint32_t)ret_conv;
17623 }
17624 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17625         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17626         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17627         return ret_conv;
17628 }
17629
17630 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
17631         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17632         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17633         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17634         return (uint32_t)ret_conv;
17635 }
17636
17637 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
17638         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17639         CHECK_ACCESS(o_ptr);
17640         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17641         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17642         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17643         *ret_copy = COption_MonitorEventZ_some(o_conv);
17644         uint32_t ret_ref = (uintptr_t)ret_copy;
17645         return ret_ref;
17646 }
17647
17648 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17649         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17650         *ret_copy = COption_MonitorEventZ_none();
17651         uint32_t ret_ref = (uintptr_t)ret_copy;
17652         return ret_ref;
17653 }
17654
17655 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
17656         if ((_res & 1) != 0) return;
17657         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17658         CHECK_ACCESS(_res_ptr);
17659         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17660         FREE((void*)_res);
17661         COption_MonitorEventZ_free(_res_conv);
17662 }
17663
17664 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17665         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17666         *ret_copy = COption_MonitorEventZ_clone(arg);
17667 uint32_t ret_ref = (uintptr_t)ret_copy;
17668         return ret_ref;
17669 }
17670 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
17671         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17672         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17673         return ret_conv;
17674 }
17675
17676 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
17677         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17678         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17679         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17680         uint32_t ret_ref = (uintptr_t)ret_copy;
17681         return ret_ref;
17682 }
17683
17684 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
17685         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17686         CHECK_ACCESS(o_ptr);
17687         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17688         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17689         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17690         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17691         return (uint32_t)ret_conv;
17692 }
17693
17694 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
17695         LDKDecodeError e_conv;
17696         e_conv.inner = (void*)(e & (~1));
17697         e_conv.is_owned = (e & 1) || (e == 0);
17698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17699         e_conv = DecodeError_clone(&e_conv);
17700         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17701         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17702         return (uint32_t)ret_conv;
17703 }
17704
17705 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
17706         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17707         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17708         return ret_conv;
17709 }
17710
17711 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17712         if ((_res & 1) != 0) return;
17713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17714         CHECK_ACCESS(_res_ptr);
17715         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17716         FREE((void*)_res);
17717         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17718 }
17719
17720 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17721         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17722         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17723         return (uint32_t)ret_conv;
17724 }
17725 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17726         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17727         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17728         return ret_conv;
17729 }
17730
17731 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17732         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17733         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17734         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17735         return (uint32_t)ret_conv;
17736 }
17737
17738 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17739         LDKHTLCUpdate o_conv;
17740         o_conv.inner = (void*)(o & (~1));
17741         o_conv.is_owned = (o & 1) || (o == 0);
17742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17743         o_conv = HTLCUpdate_clone(&o_conv);
17744         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17745         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17746         return (uint32_t)ret_conv;
17747 }
17748
17749 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17750         LDKDecodeError e_conv;
17751         e_conv.inner = (void*)(e & (~1));
17752         e_conv.is_owned = (e & 1) || (e == 0);
17753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17754         e_conv = DecodeError_clone(&e_conv);
17755         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17756         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17757         return (uint32_t)ret_conv;
17758 }
17759
17760 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17761         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17762         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17763         return ret_conv;
17764 }
17765
17766 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17767         if ((_res & 1) != 0) return;
17768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17769         CHECK_ACCESS(_res_ptr);
17770         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17771         FREE((void*)_res);
17772         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17773 }
17774
17775 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17776         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17777         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17778         return (uint32_t)ret_conv;
17779 }
17780 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17781         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17782         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17783         return ret_conv;
17784 }
17785
17786 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17787         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17788         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17789         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17790         return (uint32_t)ret_conv;
17791 }
17792
17793 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17794         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17795         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17796         return ((uint32_t)ret_conv);
17797 }
17798 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17799         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17800         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17801         return ret_conv;
17802 }
17803
17804 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17805         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17806         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17807         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17808         return ((uint32_t)ret_conv);
17809 }
17810
17811 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17812         LDKOutPoint a_conv;
17813         a_conv.inner = (void*)(a & (~1));
17814         a_conv.is_owned = (a & 1) || (a == 0);
17815         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17816         a_conv = OutPoint_clone(&a_conv);
17817         LDKCVec_u8Z b_ref;
17818         b_ref.datalen = b->arr_len;
17819         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17820         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17821         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17822         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17823         return ((uint32_t)ret_conv);
17824 }
17825
17826 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17827         if ((_res & 1) != 0) return;
17828         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17829         CHECK_ACCESS(_res_ptr);
17830         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17831         FREE((void*)_res);
17832         C2Tuple_OutPointScriptZ_free(_res_conv);
17833 }
17834
17835 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17836         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17837         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17838         return ((uint32_t)ret_conv);
17839 }
17840 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17841         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17842         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17843         return ret_conv;
17844 }
17845
17846 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17847         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17848         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17849         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17850         return ((uint32_t)ret_conv);
17851 }
17852
17853 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17854         LDKCVec_u8Z b_ref;
17855         b_ref.datalen = b->arr_len;
17856         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17857         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17858         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17859         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17860         return ((uint32_t)ret_conv);
17861 }
17862
17863 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_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         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17868         FREE((void*)_res);
17869         C2Tuple_u32ScriptZ_free(_res_conv);
17870 }
17871
17872 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17873         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17874         _res_constr.datalen = _res->arr_len;
17875         if (_res_constr.datalen > 0)
17876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17877         else
17878                 _res_constr.data = NULL;
17879         uint32_t* _res_vals = _res->elems;
17880         for (size_t v = 0; v < _res_constr.datalen; v++) {
17881                 uint32_t _res_conv_21 = _res_vals[v];
17882                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17883                 CHECK_ACCESS(_res_conv_21_ptr);
17884                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17885                 FREE((void*)_res_conv_21);
17886                 _res_constr.data[v] = _res_conv_21_conv;
17887         }
17888         FREE(_res);
17889         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17890 }
17891
17892 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17893         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17894         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17895         return ((uint32_t)ret_conv);
17896 }
17897 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17898         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17899         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17900         return ret_conv;
17901 }
17902
17903 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17904         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17905         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17906         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17907         return ((uint32_t)ret_conv);
17908 }
17909
17910 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17911         LDKThirtyTwoBytes a_ref;
17912         CHECK(a->arr_len == 32);
17913         memcpy(a_ref.data, a->elems, 32); FREE(a);
17914         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17915         b_constr.datalen = b->arr_len;
17916         if (b_constr.datalen > 0)
17917                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17918         else
17919                 b_constr.data = NULL;
17920         uint32_t* b_vals = b->elems;
17921         for (size_t v = 0; v < b_constr.datalen; v++) {
17922                 uint32_t b_conv_21 = b_vals[v];
17923                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17924                 CHECK_ACCESS(b_conv_21_ptr);
17925                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17926                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17927                 b_constr.data[v] = b_conv_21_conv;
17928         }
17929         FREE(b);
17930         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17931         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17932         return ((uint32_t)ret_conv);
17933 }
17934
17935 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17936         if ((_res & 1) != 0) return;
17937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17938         CHECK_ACCESS(_res_ptr);
17939         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17940         FREE((void*)_res);
17941         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17942 }
17943
17944 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17945         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17946         _res_constr.datalen = _res->arr_len;
17947         if (_res_constr.datalen > 0)
17948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17949         else
17950                 _res_constr.data = NULL;
17951         uint32_t* _res_vals = _res->elems;
17952         for (size_t o = 0; o < _res_constr.datalen; o++) {
17953                 uint32_t _res_conv_40 = _res_vals[o];
17954                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17955                 CHECK_ACCESS(_res_conv_40_ptr);
17956                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17957                 FREE((void*)_res_conv_40);
17958                 _res_constr.data[o] = _res_conv_40_conv;
17959         }
17960         FREE(_res);
17961         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17962 }
17963
17964 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17965         LDKCVec_EventZ _res_constr;
17966         _res_constr.datalen = _res->arr_len;
17967         if (_res_constr.datalen > 0)
17968                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17969         else
17970                 _res_constr.data = NULL;
17971         uint32_t* _res_vals = _res->elems;
17972         for (size_t h = 0; h < _res_constr.datalen; h++) {
17973                 uint32_t _res_conv_7 = _res_vals[h];
17974                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17975                 CHECK_ACCESS(_res_conv_7_ptr);
17976                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17977                 FREE((void*)_res_conv_7);
17978                 _res_constr.data[h] = _res_conv_7_conv;
17979         }
17980         FREE(_res);
17981         CVec_EventZ_free(_res_constr);
17982 }
17983
17984 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17985         LDKCVec_TransactionZ _res_constr;
17986         _res_constr.datalen = _res->arr_len;
17987         if (_res_constr.datalen > 0)
17988                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17989         else
17990                 _res_constr.data = NULL;
17991         int8_tArray* _res_vals = (void*) _res->elems;
17992         for (size_t m = 0; m < _res_constr.datalen; m++) {
17993                 int8_tArray _res_conv_12 = _res_vals[m];
17994                 LDKTransaction _res_conv_12_ref;
17995                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17996                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17997                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17998                 _res_conv_12_ref.data_is_owned = true;
17999                 _res_constr.data[m] = _res_conv_12_ref;
18000         }
18001         FREE(_res);
18002         CVec_TransactionZ_free(_res_constr);
18003 }
18004
18005 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
18006         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18007         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
18008         return ((uint32_t)ret_conv);
18009 }
18010 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
18011         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
18012         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
18013         return ret_conv;
18014 }
18015
18016 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
18017         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
18018         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18019         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
18020         return ((uint32_t)ret_conv);
18021 }
18022
18023 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
18024         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18025         CHECK_ACCESS(b_ptr);
18026         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
18027         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
18028         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18029         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
18030         return ((uint32_t)ret_conv);
18031 }
18032
18033 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
18034         if ((_res & 1) != 0) return;
18035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18036         CHECK_ACCESS(_res_ptr);
18037         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
18038         FREE((void*)_res);
18039         C2Tuple_u32TxOutZ_free(_res_conv);
18040 }
18041
18042 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
18043         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
18044         _res_constr.datalen = _res->arr_len;
18045         if (_res_constr.datalen > 0)
18046                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18047         else
18048                 _res_constr.data = NULL;
18049         uint32_t* _res_vals = _res->elems;
18050         for (size_t u = 0; u < _res_constr.datalen; u++) {
18051                 uint32_t _res_conv_20 = _res_vals[u];
18052                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
18053                 CHECK_ACCESS(_res_conv_20_ptr);
18054                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
18055                 FREE((void*)_res_conv_20);
18056                 _res_constr.data[u] = _res_conv_20_conv;
18057         }
18058         FREE(_res);
18059         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
18060 }
18061
18062 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
18063         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18064         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
18065         return ((uint32_t)ret_conv);
18066 }
18067 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
18068         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
18069         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
18070         return ret_conv;
18071 }
18072
18073 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
18074         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
18075         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18076         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
18077         return ((uint32_t)ret_conv);
18078 }
18079
18080 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
18081         LDKThirtyTwoBytes a_ref;
18082         CHECK(a->arr_len == 32);
18083         memcpy(a_ref.data, a->elems, 32); FREE(a);
18084         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
18085         b_constr.datalen = b->arr_len;
18086         if (b_constr.datalen > 0)
18087                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18088         else
18089                 b_constr.data = NULL;
18090         uint32_t* b_vals = b->elems;
18091         for (size_t u = 0; u < b_constr.datalen; u++) {
18092                 uint32_t b_conv_20 = b_vals[u];
18093                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
18094                 CHECK_ACCESS(b_conv_20_ptr);
18095                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
18096                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
18097                 b_constr.data[u] = b_conv_20_conv;
18098         }
18099         FREE(b);
18100         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18101         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
18102         return ((uint32_t)ret_conv);
18103 }
18104
18105 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
18106         if ((_res & 1) != 0) return;
18107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18108         CHECK_ACCESS(_res_ptr);
18109         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
18110         FREE((void*)_res);
18111         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
18112 }
18113
18114 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
18115         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
18116         _res_constr.datalen = _res->arr_len;
18117         if (_res_constr.datalen > 0)
18118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
18119         else
18120                 _res_constr.data = NULL;
18121         uint32_t* _res_vals = _res->elems;
18122         for (size_t n = 0; n < _res_constr.datalen; n++) {
18123                 uint32_t _res_conv_39 = _res_vals[n];
18124                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
18125                 CHECK_ACCESS(_res_conv_39_ptr);
18126                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
18127                 FREE((void*)_res_conv_39);
18128                 _res_constr.data[n] = _res_conv_39_conv;
18129         }
18130         FREE(_res);
18131         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
18132 }
18133
18134 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
18135         LDKCVec_BalanceZ _res_constr;
18136         _res_constr.datalen = _res->arr_len;
18137         if (_res_constr.datalen > 0)
18138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
18139         else
18140                 _res_constr.data = NULL;
18141         uint32_t* _res_vals = _res->elems;
18142         for (size_t j = 0; j < _res_constr.datalen; j++) {
18143                 uint32_t _res_conv_9 = _res_vals[j];
18144                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
18145                 CHECK_ACCESS(_res_conv_9_ptr);
18146                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
18147                 FREE((void*)_res_conv_9);
18148                 _res_constr.data[j] = _res_conv_9_conv;
18149         }
18150         FREE(_res);
18151         CVec_BalanceZ_free(_res_constr);
18152 }
18153
18154 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18155         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18156         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18157         return ((uint32_t)ret_conv);
18158 }
18159 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
18160         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18161         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18162         return ret_conv;
18163 }
18164
18165 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
18166         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18167         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18168         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18169         return ((uint32_t)ret_conv);
18170 }
18171
18172 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
18173         LDKThirtyTwoBytes a_ref;
18174         CHECK(a->arr_len == 32);
18175         memcpy(a_ref.data, a->elems, 32); FREE(a);
18176         LDKChannelMonitor b_conv;
18177         b_conv.inner = (void*)(b & (~1));
18178         b_conv.is_owned = (b & 1) || (b == 0);
18179         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18180         b_conv = ChannelMonitor_clone(&b_conv);
18181         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18182         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18183         return ((uint32_t)ret_conv);
18184 }
18185
18186 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
18187         if ((_res & 1) != 0) return;
18188         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18189         CHECK_ACCESS(_res_ptr);
18190         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18191         FREE((void*)_res);
18192         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18193 }
18194
18195 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
18196         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18197         CHECK_ACCESS(o_ptr);
18198         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
18199         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
18200         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18201         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
18202         return (uint32_t)ret_conv;
18203 }
18204
18205 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
18206         LDKDecodeError e_conv;
18207         e_conv.inner = (void*)(e & (~1));
18208         e_conv.is_owned = (e & 1) || (e == 0);
18209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18210         e_conv = DecodeError_clone(&e_conv);
18211         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18212         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
18213         return (uint32_t)ret_conv;
18214 }
18215
18216 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
18217         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
18218         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
18219         return ret_conv;
18220 }
18221
18222 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
18223         if ((_res & 1) != 0) return;
18224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18225         CHECK_ACCESS(_res_ptr);
18226         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
18227         FREE((void*)_res);
18228         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
18229 }
18230
18231 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
18232         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18233         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
18234         return (uint32_t)ret_conv;
18235 }
18236 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
18237         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
18238         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
18239         return ret_conv;
18240 }
18241
18242 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
18243         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
18244         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18245         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
18246         return (uint32_t)ret_conv;
18247 }
18248
18249 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
18250         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18251         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
18252         return ((uint32_t)ret_conv);
18253 }
18254 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
18255         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
18256         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
18257         return ret_conv;
18258 }
18259
18260 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
18261         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
18262         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18263         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
18264         return ((uint32_t)ret_conv);
18265 }
18266
18267 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
18268         LDKPublicKey a_ref;
18269         CHECK(a->arr_len == 33);
18270         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
18271         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18272         CHECK_ACCESS(b_ptr);
18273         LDKType b_conv = *(LDKType*)(b_ptr);
18274         if (b_conv.free == LDKType_JCalls_free) {
18275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18276                 LDKType_JCalls_cloned(&b_conv);
18277         }
18278         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18279         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
18280         return ((uint32_t)ret_conv);
18281 }
18282
18283 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
18284         if ((_res & 1) != 0) return;
18285         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18286         CHECK_ACCESS(_res_ptr);
18287         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
18288         FREE((void*)_res);
18289         C2Tuple_PublicKeyTypeZ_free(_res_conv);
18290 }
18291
18292 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
18293         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
18294         _res_constr.datalen = _res->arr_len;
18295         if (_res_constr.datalen > 0)
18296                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
18297         else
18298                 _res_constr.data = NULL;
18299         uint32_t* _res_vals = _res->elems;
18300         for (size_t z = 0; z < _res_constr.datalen; z++) {
18301                 uint32_t _res_conv_25 = _res_vals[z];
18302                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
18303                 CHECK_ACCESS(_res_conv_25_ptr);
18304                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
18305                 FREE((void*)_res_conv_25);
18306                 _res_constr.data[z] = _res_conv_25_conv;
18307         }
18308         FREE(_res);
18309         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
18310 }
18311
18312 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
18313         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18314         CHECK_ACCESS(o_ptr);
18315         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18316         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18317         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18318         *ret_copy = COption_NetAddressZ_some(o_conv);
18319         uint32_t ret_ref = (uintptr_t)ret_copy;
18320         return ret_ref;
18321 }
18322
18323 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
18324         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18325         *ret_copy = COption_NetAddressZ_none();
18326         uint32_t ret_ref = (uintptr_t)ret_copy;
18327         return ret_ref;
18328 }
18329
18330 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
18331         if ((_res & 1) != 0) return;
18332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18333         CHECK_ACCESS(_res_ptr);
18334         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
18335         FREE((void*)_res);
18336         COption_NetAddressZ_free(_res_conv);
18337 }
18338
18339 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
18340         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18341         *ret_copy = COption_NetAddressZ_clone(arg);
18342 uint32_t ret_ref = (uintptr_t)ret_copy;
18343         return ret_ref;
18344 }
18345 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
18346         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
18347         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
18348         return ret_conv;
18349 }
18350
18351 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
18352         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
18353         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18354         *ret_copy = COption_NetAddressZ_clone(orig_conv);
18355         uint32_t ret_ref = (uintptr_t)ret_copy;
18356         return ret_ref;
18357 }
18358
18359 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
18360         LDKCVec_u8Z o_ref;
18361         o_ref.datalen = o->arr_len;
18362         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
18363         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
18364         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18365         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
18366         return (uint32_t)ret_conv;
18367 }
18368
18369 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
18370         LDKPeerHandleError e_conv;
18371         e_conv.inner = (void*)(e & (~1));
18372         e_conv.is_owned = (e & 1) || (e == 0);
18373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18374         e_conv = PeerHandleError_clone(&e_conv);
18375         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18376         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
18377         return (uint32_t)ret_conv;
18378 }
18379
18380 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
18381         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
18382         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
18383         return ret_conv;
18384 }
18385
18386 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
18387         if ((_res & 1) != 0) return;
18388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18389         CHECK_ACCESS(_res_ptr);
18390         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
18391         FREE((void*)_res);
18392         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18393 }
18394
18395 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18396         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18397         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18398         return (uint32_t)ret_conv;
18399 }
18400 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18401         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18402         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18403         return ret_conv;
18404 }
18405
18406 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
18407         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18408         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18409         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18410         return (uint32_t)ret_conv;
18411 }
18412
18413 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18414         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18415         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
18420         LDKPeerHandleError e_conv;
18421         e_conv.inner = (void*)(e & (~1));
18422         e_conv.is_owned = (e & 1) || (e == 0);
18423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18424         e_conv = PeerHandleError_clone(&e_conv);
18425         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18426         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
18431         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18432         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18433         return ret_conv;
18434 }
18435
18436 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
18437         if ((_res & 1) != 0) return;
18438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18439         CHECK_ACCESS(_res_ptr);
18440         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18441         FREE((void*)_res);
18442         CResult_NonePeerHandleErrorZ_free(_res_conv);
18443 }
18444
18445 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18446         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18447         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18448         return (uint32_t)ret_conv;
18449 }
18450 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
18451         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18452         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18453         return ret_conv;
18454 }
18455
18456 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
18457         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18458         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18459         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18460         return (uint32_t)ret_conv;
18461 }
18462
18463 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18464         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18465         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18466         return (uint32_t)ret_conv;
18467 }
18468
18469 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
18470         LDKPeerHandleError e_conv;
18471         e_conv.inner = (void*)(e & (~1));
18472         e_conv.is_owned = (e & 1) || (e == 0);
18473         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18474         e_conv = PeerHandleError_clone(&e_conv);
18475         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18476         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18477         return (uint32_t)ret_conv;
18478 }
18479
18480 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
18481         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18482         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18483         return ret_conv;
18484 }
18485
18486 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
18487         if ((_res & 1) != 0) return;
18488         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18489         CHECK_ACCESS(_res_ptr);
18490         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18491         FREE((void*)_res);
18492         CResult_boolPeerHandleErrorZ_free(_res_conv);
18493 }
18494
18495 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18496         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18497         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18498         return (uint32_t)ret_conv;
18499 }
18500 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18501         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18502         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18503         return ret_conv;
18504 }
18505
18506 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
18507         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18508         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18509         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18510         return (uint32_t)ret_conv;
18511 }
18512
18513 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18514         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18515         *ret_conv = CResult_NoneErrorZ_ok();
18516         return (uint32_t)ret_conv;
18517 }
18518
18519 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18520         LDKIOError e_conv = LDKIOError_from_js(e);
18521         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18522         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18523         return (uint32_t)ret_conv;
18524 }
18525
18526 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
18527         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
18528         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18529         return ret_conv;
18530 }
18531
18532 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
18533         if ((_res & 1) != 0) return;
18534         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18535         CHECK_ACCESS(_res_ptr);
18536         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18537         FREE((void*)_res);
18538         CResult_NoneErrorZ_free(_res_conv);
18539 }
18540
18541 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18542         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18543         *ret_conv = CResult_NoneErrorZ_clone(arg);
18544         return (uint32_t)ret_conv;
18545 }
18546 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
18547         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
18548         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18549         return ret_conv;
18550 }
18551
18552 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
18553         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
18554         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18555         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18556         return (uint32_t)ret_conv;
18557 }
18558
18559 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
18560         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18561         CHECK_ACCESS(o_ptr);
18562         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18563         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18564         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18565         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18566         return (uint32_t)ret_conv;
18567 }
18568
18569 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
18570         LDKDecodeError e_conv;
18571         e_conv.inner = (void*)(e & (~1));
18572         e_conv.is_owned = (e & 1) || (e == 0);
18573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18574         e_conv = DecodeError_clone(&e_conv);
18575         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18576         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18577         return (uint32_t)ret_conv;
18578 }
18579
18580 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
18581         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
18582         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18583         return ret_conv;
18584 }
18585
18586 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
18587         if ((_res & 1) != 0) return;
18588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18589         CHECK_ACCESS(_res_ptr);
18590         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18591         FREE((void*)_res);
18592         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18593 }
18594
18595 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18596         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18597         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18598         return (uint32_t)ret_conv;
18599 }
18600 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
18601         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
18602         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18603         return ret_conv;
18604 }
18605
18606 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
18607         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
18608         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18609         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18610         return (uint32_t)ret_conv;
18611 }
18612
18613 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
18614         LDKCVec_UpdateAddHTLCZ _res_constr;
18615         _res_constr.datalen = _res->arr_len;
18616         if (_res_constr.datalen > 0)
18617                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18618         else
18619                 _res_constr.data = NULL;
18620         uint32_t* _res_vals = _res->elems;
18621         for (size_t p = 0; p < _res_constr.datalen; p++) {
18622                 uint32_t _res_conv_15 = _res_vals[p];
18623                 LDKUpdateAddHTLC _res_conv_15_conv;
18624                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
18625                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
18626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18627                 _res_constr.data[p] = _res_conv_15_conv;
18628         }
18629         FREE(_res);
18630         CVec_UpdateAddHTLCZ_free(_res_constr);
18631 }
18632
18633 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
18634         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18635         _res_constr.datalen = _res->arr_len;
18636         if (_res_constr.datalen > 0)
18637                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18638         else
18639                 _res_constr.data = NULL;
18640         uint32_t* _res_vals = _res->elems;
18641         for (size_t t = 0; t < _res_constr.datalen; t++) {
18642                 uint32_t _res_conv_19 = _res_vals[t];
18643                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18644                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
18645                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
18646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18647                 _res_constr.data[t] = _res_conv_19_conv;
18648         }
18649         FREE(_res);
18650         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18651 }
18652
18653 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
18654         LDKCVec_UpdateFailHTLCZ _res_constr;
18655         _res_constr.datalen = _res->arr_len;
18656         if (_res_constr.datalen > 0)
18657                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18658         else
18659                 _res_constr.data = NULL;
18660         uint32_t* _res_vals = _res->elems;
18661         for (size_t q = 0; q < _res_constr.datalen; q++) {
18662                 uint32_t _res_conv_16 = _res_vals[q];
18663                 LDKUpdateFailHTLC _res_conv_16_conv;
18664                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18665                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18666                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18667                 _res_constr.data[q] = _res_conv_16_conv;
18668         }
18669         FREE(_res);
18670         CVec_UpdateFailHTLCZ_free(_res_constr);
18671 }
18672
18673 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
18674         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18675         _res_constr.datalen = _res->arr_len;
18676         if (_res_constr.datalen > 0)
18677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18678         else
18679                 _res_constr.data = NULL;
18680         uint32_t* _res_vals = _res->elems;
18681         for (size_t z = 0; z < _res_constr.datalen; z++) {
18682                 uint32_t _res_conv_25 = _res_vals[z];
18683                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18684                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18685                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18686                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18687                 _res_constr.data[z] = _res_conv_25_conv;
18688         }
18689         FREE(_res);
18690         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18691 }
18692
18693 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
18694         LDKAcceptChannel o_conv;
18695         o_conv.inner = (void*)(o & (~1));
18696         o_conv.is_owned = (o & 1) || (o == 0);
18697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18698         o_conv = AcceptChannel_clone(&o_conv);
18699         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18700         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18701         return (uint32_t)ret_conv;
18702 }
18703
18704 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
18705         LDKDecodeError e_conv;
18706         e_conv.inner = (void*)(e & (~1));
18707         e_conv.is_owned = (e & 1) || (e == 0);
18708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18709         e_conv = DecodeError_clone(&e_conv);
18710         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18711         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18712         return (uint32_t)ret_conv;
18713 }
18714
18715 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
18716         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18717         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18718         return ret_conv;
18719 }
18720
18721 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
18722         if ((_res & 1) != 0) return;
18723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18724         CHECK_ACCESS(_res_ptr);
18725         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18726         FREE((void*)_res);
18727         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18728 }
18729
18730 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18731         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18732         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18733         return (uint32_t)ret_conv;
18734 }
18735 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18736         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18737         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18738         return ret_conv;
18739 }
18740
18741 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18742         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18743         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18744         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18745         return (uint32_t)ret_conv;
18746 }
18747
18748 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18749         LDKAnnouncementSignatures o_conv;
18750         o_conv.inner = (void*)(o & (~1));
18751         o_conv.is_owned = (o & 1) || (o == 0);
18752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18753         o_conv = AnnouncementSignatures_clone(&o_conv);
18754         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18755         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18756         return (uint32_t)ret_conv;
18757 }
18758
18759 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18760         LDKDecodeError e_conv;
18761         e_conv.inner = (void*)(e & (~1));
18762         e_conv.is_owned = (e & 1) || (e == 0);
18763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18764         e_conv = DecodeError_clone(&e_conv);
18765         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18766         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18767         return (uint32_t)ret_conv;
18768 }
18769
18770 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18771         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18772         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18773         return ret_conv;
18774 }
18775
18776 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18777         if ((_res & 1) != 0) return;
18778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18779         CHECK_ACCESS(_res_ptr);
18780         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18781         FREE((void*)_res);
18782         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18783 }
18784
18785 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18786         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18787         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18788         return (uint32_t)ret_conv;
18789 }
18790 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18791         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18792         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18793         return ret_conv;
18794 }
18795
18796 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18797         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18798         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18799         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18800         return (uint32_t)ret_conv;
18801 }
18802
18803 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18804         LDKChannelReestablish o_conv;
18805         o_conv.inner = (void*)(o & (~1));
18806         o_conv.is_owned = (o & 1) || (o == 0);
18807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18808         o_conv = ChannelReestablish_clone(&o_conv);
18809         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18810         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18811         return (uint32_t)ret_conv;
18812 }
18813
18814 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18815         LDKDecodeError e_conv;
18816         e_conv.inner = (void*)(e & (~1));
18817         e_conv.is_owned = (e & 1) || (e == 0);
18818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18819         e_conv = DecodeError_clone(&e_conv);
18820         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18821         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18822         return (uint32_t)ret_conv;
18823 }
18824
18825 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18826         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18827         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18828         return ret_conv;
18829 }
18830
18831 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
18832         if ((_res & 1) != 0) return;
18833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18834         CHECK_ACCESS(_res_ptr);
18835         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18836         FREE((void*)_res);
18837         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18838 }
18839
18840 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18841         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18842         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18843         return (uint32_t)ret_conv;
18844 }
18845 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18846         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18847         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18848         return ret_conv;
18849 }
18850
18851 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18852         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18853         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18854         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18855         return (uint32_t)ret_conv;
18856 }
18857
18858 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18859         LDKClosingSigned o_conv;
18860         o_conv.inner = (void*)(o & (~1));
18861         o_conv.is_owned = (o & 1) || (o == 0);
18862         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18863         o_conv = ClosingSigned_clone(&o_conv);
18864         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18865         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18866         return (uint32_t)ret_conv;
18867 }
18868
18869 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18870         LDKDecodeError e_conv;
18871         e_conv.inner = (void*)(e & (~1));
18872         e_conv.is_owned = (e & 1) || (e == 0);
18873         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18874         e_conv = DecodeError_clone(&e_conv);
18875         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18876         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18877         return (uint32_t)ret_conv;
18878 }
18879
18880 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18881         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18882         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18883         return ret_conv;
18884 }
18885
18886 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18887         if ((_res & 1) != 0) return;
18888         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18889         CHECK_ACCESS(_res_ptr);
18890         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18891         FREE((void*)_res);
18892         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18893 }
18894
18895 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18896         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18897         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18898         return (uint32_t)ret_conv;
18899 }
18900 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18901         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18902         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18903         return ret_conv;
18904 }
18905
18906 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18907         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18908         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18909         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18910         return (uint32_t)ret_conv;
18911 }
18912
18913 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18914         LDKClosingSignedFeeRange o_conv;
18915         o_conv.inner = (void*)(o & (~1));
18916         o_conv.is_owned = (o & 1) || (o == 0);
18917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18918         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18919         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18920         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18921         return (uint32_t)ret_conv;
18922 }
18923
18924 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18925         LDKDecodeError e_conv;
18926         e_conv.inner = (void*)(e & (~1));
18927         e_conv.is_owned = (e & 1) || (e == 0);
18928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18929         e_conv = DecodeError_clone(&e_conv);
18930         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18931         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18932         return (uint32_t)ret_conv;
18933 }
18934
18935 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18936         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18937         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18938         return ret_conv;
18939 }
18940
18941 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18942         if ((_res & 1) != 0) return;
18943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18944         CHECK_ACCESS(_res_ptr);
18945         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18946         FREE((void*)_res);
18947         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18948 }
18949
18950 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18951         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18952         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18953         return (uint32_t)ret_conv;
18954 }
18955 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18956         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18957         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18958         return ret_conv;
18959 }
18960
18961 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18962         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18963         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18964         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18965         return (uint32_t)ret_conv;
18966 }
18967
18968 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18969         LDKCommitmentSigned o_conv;
18970         o_conv.inner = (void*)(o & (~1));
18971         o_conv.is_owned = (o & 1) || (o == 0);
18972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18973         o_conv = CommitmentSigned_clone(&o_conv);
18974         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18975         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18976         return (uint32_t)ret_conv;
18977 }
18978
18979 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18980         LDKDecodeError e_conv;
18981         e_conv.inner = (void*)(e & (~1));
18982         e_conv.is_owned = (e & 1) || (e == 0);
18983         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18984         e_conv = DecodeError_clone(&e_conv);
18985         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18986         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18987         return (uint32_t)ret_conv;
18988 }
18989
18990 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18991         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18992         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18993         return ret_conv;
18994 }
18995
18996 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18997         if ((_res & 1) != 0) return;
18998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18999         CHECK_ACCESS(_res_ptr);
19000         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
19001         FREE((void*)_res);
19002         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
19003 }
19004
19005 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
19006         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19007         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
19008         return (uint32_t)ret_conv;
19009 }
19010 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19011         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
19012         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
19013         return ret_conv;
19014 }
19015
19016 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
19017         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
19018         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19019         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
19020         return (uint32_t)ret_conv;
19021 }
19022
19023 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
19024         LDKFundingCreated o_conv;
19025         o_conv.inner = (void*)(o & (~1));
19026         o_conv.is_owned = (o & 1) || (o == 0);
19027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19028         o_conv = FundingCreated_clone(&o_conv);
19029         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19030         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
19031         return (uint32_t)ret_conv;
19032 }
19033
19034 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
19035         LDKDecodeError e_conv;
19036         e_conv.inner = (void*)(e & (~1));
19037         e_conv.is_owned = (e & 1) || (e == 0);
19038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19039         e_conv = DecodeError_clone(&e_conv);
19040         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19041         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
19042         return (uint32_t)ret_conv;
19043 }
19044
19045 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
19046         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
19047         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
19048         return ret_conv;
19049 }
19050
19051 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
19052         if ((_res & 1) != 0) return;
19053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19054         CHECK_ACCESS(_res_ptr);
19055         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
19056         FREE((void*)_res);
19057         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
19058 }
19059
19060 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
19061         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19062         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
19063         return (uint32_t)ret_conv;
19064 }
19065 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
19066         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
19067         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
19068         return ret_conv;
19069 }
19070
19071 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
19072         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
19073         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19074         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
19075         return (uint32_t)ret_conv;
19076 }
19077
19078 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
19079         LDKFundingSigned o_conv;
19080         o_conv.inner = (void*)(o & (~1));
19081         o_conv.is_owned = (o & 1) || (o == 0);
19082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19083         o_conv = FundingSigned_clone(&o_conv);
19084         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19085         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
19086         return (uint32_t)ret_conv;
19087 }
19088
19089 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
19090         LDKDecodeError e_conv;
19091         e_conv.inner = (void*)(e & (~1));
19092         e_conv.is_owned = (e & 1) || (e == 0);
19093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19094         e_conv = DecodeError_clone(&e_conv);
19095         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19096         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
19097         return (uint32_t)ret_conv;
19098 }
19099
19100 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
19101         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
19102         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
19103         return ret_conv;
19104 }
19105
19106 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
19107         if ((_res & 1) != 0) return;
19108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19109         CHECK_ACCESS(_res_ptr);
19110         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
19111         FREE((void*)_res);
19112         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
19113 }
19114
19115 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
19116         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19117         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
19118         return (uint32_t)ret_conv;
19119 }
19120 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19121         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
19122         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
19123         return ret_conv;
19124 }
19125
19126 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
19127         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
19128         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19129         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
19130         return (uint32_t)ret_conv;
19131 }
19132
19133 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
19134         LDKChannelReady o_conv;
19135         o_conv.inner = (void*)(o & (~1));
19136         o_conv.is_owned = (o & 1) || (o == 0);
19137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19138         o_conv = ChannelReady_clone(&o_conv);
19139         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19140         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
19141         return (uint32_t)ret_conv;
19142 }
19143
19144 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
19145         LDKDecodeError e_conv;
19146         e_conv.inner = (void*)(e & (~1));
19147         e_conv.is_owned = (e & 1) || (e == 0);
19148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19149         e_conv = DecodeError_clone(&e_conv);
19150         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19151         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
19152         return (uint32_t)ret_conv;
19153 }
19154
19155 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
19156         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
19157         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
19158         return ret_conv;
19159 }
19160
19161 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
19162         if ((_res & 1) != 0) return;
19163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19164         CHECK_ACCESS(_res_ptr);
19165         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
19166         FREE((void*)_res);
19167         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
19168 }
19169
19170 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
19171         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19172         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
19173         return (uint32_t)ret_conv;
19174 }
19175 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
19176         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
19177         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
19178         return ret_conv;
19179 }
19180
19181 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
19182         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
19183         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19184         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
19185         return (uint32_t)ret_conv;
19186 }
19187
19188 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
19189         LDKInit o_conv;
19190         o_conv.inner = (void*)(o & (~1));
19191         o_conv.is_owned = (o & 1) || (o == 0);
19192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19193         o_conv = Init_clone(&o_conv);
19194         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19195         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
19196         return (uint32_t)ret_conv;
19197 }
19198
19199 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
19200         LDKDecodeError e_conv;
19201         e_conv.inner = (void*)(e & (~1));
19202         e_conv.is_owned = (e & 1) || (e == 0);
19203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19204         e_conv = DecodeError_clone(&e_conv);
19205         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19206         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
19207         return (uint32_t)ret_conv;
19208 }
19209
19210 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
19211         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
19212         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
19213         return ret_conv;
19214 }
19215
19216 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
19217         if ((_res & 1) != 0) return;
19218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19219         CHECK_ACCESS(_res_ptr);
19220         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
19221         FREE((void*)_res);
19222         CResult_InitDecodeErrorZ_free(_res_conv);
19223 }
19224
19225 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
19226         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19227         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
19228         return (uint32_t)ret_conv;
19229 }
19230 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
19231         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
19232         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
19233         return ret_conv;
19234 }
19235
19236 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
19237         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
19238         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19239         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
19240         return (uint32_t)ret_conv;
19241 }
19242
19243 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
19244         LDKOpenChannel o_conv;
19245         o_conv.inner = (void*)(o & (~1));
19246         o_conv.is_owned = (o & 1) || (o == 0);
19247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19248         o_conv = OpenChannel_clone(&o_conv);
19249         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19250         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
19251         return (uint32_t)ret_conv;
19252 }
19253
19254 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
19255         LDKDecodeError e_conv;
19256         e_conv.inner = (void*)(e & (~1));
19257         e_conv.is_owned = (e & 1) || (e == 0);
19258         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19259         e_conv = DecodeError_clone(&e_conv);
19260         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19261         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
19262         return (uint32_t)ret_conv;
19263 }
19264
19265 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
19266         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
19267         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
19268         return ret_conv;
19269 }
19270
19271 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
19272         if ((_res & 1) != 0) return;
19273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19274         CHECK_ACCESS(_res_ptr);
19275         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
19276         FREE((void*)_res);
19277         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
19278 }
19279
19280 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
19281         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19282         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
19283         return (uint32_t)ret_conv;
19284 }
19285 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
19286         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
19287         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
19288         return ret_conv;
19289 }
19290
19291 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
19292         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
19293         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19294         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
19295         return (uint32_t)ret_conv;
19296 }
19297
19298 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
19299         LDKRevokeAndACK o_conv;
19300         o_conv.inner = (void*)(o & (~1));
19301         o_conv.is_owned = (o & 1) || (o == 0);
19302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19303         o_conv = RevokeAndACK_clone(&o_conv);
19304         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19305         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
19306         return (uint32_t)ret_conv;
19307 }
19308
19309 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
19310         LDKDecodeError e_conv;
19311         e_conv.inner = (void*)(e & (~1));
19312         e_conv.is_owned = (e & 1) || (e == 0);
19313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19314         e_conv = DecodeError_clone(&e_conv);
19315         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19316         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
19317         return (uint32_t)ret_conv;
19318 }
19319
19320 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
19321         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
19322         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
19323         return ret_conv;
19324 }
19325
19326 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
19327         if ((_res & 1) != 0) return;
19328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19329         CHECK_ACCESS(_res_ptr);
19330         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
19331         FREE((void*)_res);
19332         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
19333 }
19334
19335 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
19336         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19337         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
19338         return (uint32_t)ret_conv;
19339 }
19340 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
19341         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
19342         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
19343         return ret_conv;
19344 }
19345
19346 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
19347         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
19348         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19349         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
19350         return (uint32_t)ret_conv;
19351 }
19352
19353 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
19354         LDKShutdown o_conv;
19355         o_conv.inner = (void*)(o & (~1));
19356         o_conv.is_owned = (o & 1) || (o == 0);
19357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19358         o_conv = Shutdown_clone(&o_conv);
19359         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19360         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
19361         return (uint32_t)ret_conv;
19362 }
19363
19364 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
19365         LDKDecodeError e_conv;
19366         e_conv.inner = (void*)(e & (~1));
19367         e_conv.is_owned = (e & 1) || (e == 0);
19368         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19369         e_conv = DecodeError_clone(&e_conv);
19370         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19371         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
19372         return (uint32_t)ret_conv;
19373 }
19374
19375 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
19376         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
19377         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
19378         return ret_conv;
19379 }
19380
19381 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
19382         if ((_res & 1) != 0) return;
19383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19384         CHECK_ACCESS(_res_ptr);
19385         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
19386         FREE((void*)_res);
19387         CResult_ShutdownDecodeErrorZ_free(_res_conv);
19388 }
19389
19390 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
19391         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19392         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
19393         return (uint32_t)ret_conv;
19394 }
19395 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
19396         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
19397         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19398         return ret_conv;
19399 }
19400
19401 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
19402         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
19403         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19404         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19405         return (uint32_t)ret_conv;
19406 }
19407
19408 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
19409         LDKUpdateFailHTLC o_conv;
19410         o_conv.inner = (void*)(o & (~1));
19411         o_conv.is_owned = (o & 1) || (o == 0);
19412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19413         o_conv = UpdateFailHTLC_clone(&o_conv);
19414         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19415         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19416         return (uint32_t)ret_conv;
19417 }
19418
19419 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
19420         LDKDecodeError e_conv;
19421         e_conv.inner = (void*)(e & (~1));
19422         e_conv.is_owned = (e & 1) || (e == 0);
19423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19424         e_conv = DecodeError_clone(&e_conv);
19425         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19426         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19427         return (uint32_t)ret_conv;
19428 }
19429
19430 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
19431         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
19432         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19433         return ret_conv;
19434 }
19435
19436 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
19437         if ((_res & 1) != 0) return;
19438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19439         CHECK_ACCESS(_res_ptr);
19440         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19441         FREE((void*)_res);
19442         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19443 }
19444
19445 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19446         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19447         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19448         return (uint32_t)ret_conv;
19449 }
19450 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19451         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
19452         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19453         return ret_conv;
19454 }
19455
19456 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
19457         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
19458         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19459         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19460         return (uint32_t)ret_conv;
19461 }
19462
19463 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
19464         LDKUpdateFailMalformedHTLC o_conv;
19465         o_conv.inner = (void*)(o & (~1));
19466         o_conv.is_owned = (o & 1) || (o == 0);
19467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19468         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19469         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19470         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19471         return (uint32_t)ret_conv;
19472 }
19473
19474 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
19475         LDKDecodeError e_conv;
19476         e_conv.inner = (void*)(e & (~1));
19477         e_conv.is_owned = (e & 1) || (e == 0);
19478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19479         e_conv = DecodeError_clone(&e_conv);
19480         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19481         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19482         return (uint32_t)ret_conv;
19483 }
19484
19485 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
19486         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
19487         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19488         return ret_conv;
19489 }
19490
19491 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
19492         if ((_res & 1) != 0) return;
19493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19494         CHECK_ACCESS(_res_ptr);
19495         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19496         FREE((void*)_res);
19497         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19498 }
19499
19500 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19501         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19502         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19503         return (uint32_t)ret_conv;
19504 }
19505 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19506         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
19507         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19508         return ret_conv;
19509 }
19510
19511 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
19512         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
19513         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19514         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19515         return (uint32_t)ret_conv;
19516 }
19517
19518 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
19519         LDKUpdateFee o_conv;
19520         o_conv.inner = (void*)(o & (~1));
19521         o_conv.is_owned = (o & 1) || (o == 0);
19522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19523         o_conv = UpdateFee_clone(&o_conv);
19524         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19525         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19526         return (uint32_t)ret_conv;
19527 }
19528
19529 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
19530         LDKDecodeError e_conv;
19531         e_conv.inner = (void*)(e & (~1));
19532         e_conv.is_owned = (e & 1) || (e == 0);
19533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19534         e_conv = DecodeError_clone(&e_conv);
19535         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19536         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19537         return (uint32_t)ret_conv;
19538 }
19539
19540 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
19541         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
19542         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19543         return ret_conv;
19544 }
19545
19546 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
19547         if ((_res & 1) != 0) return;
19548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19549         CHECK_ACCESS(_res_ptr);
19550         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19551         FREE((void*)_res);
19552         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19553 }
19554
19555 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19556         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19557         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19558         return (uint32_t)ret_conv;
19559 }
19560 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
19561         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
19562         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19563         return ret_conv;
19564 }
19565
19566 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
19567         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
19568         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19569         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19570         return (uint32_t)ret_conv;
19571 }
19572
19573 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
19574         LDKUpdateFulfillHTLC o_conv;
19575         o_conv.inner = (void*)(o & (~1));
19576         o_conv.is_owned = (o & 1) || (o == 0);
19577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19578         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19579         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19580         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19581         return (uint32_t)ret_conv;
19582 }
19583
19584 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
19585         LDKDecodeError e_conv;
19586         e_conv.inner = (void*)(e & (~1));
19587         e_conv.is_owned = (e & 1) || (e == 0);
19588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19589         e_conv = DecodeError_clone(&e_conv);
19590         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19591         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19592         return (uint32_t)ret_conv;
19593 }
19594
19595 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
19596         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
19597         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19598         return ret_conv;
19599 }
19600
19601 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
19602         if ((_res & 1) != 0) return;
19603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19604         CHECK_ACCESS(_res_ptr);
19605         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19606         FREE((void*)_res);
19607         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19608 }
19609
19610 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19611         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19612         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19613         return (uint32_t)ret_conv;
19614 }
19615 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19616         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
19617         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19618         return ret_conv;
19619 }
19620
19621 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
19622         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
19623         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19624         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19625         return (uint32_t)ret_conv;
19626 }
19627
19628 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
19629         LDKUpdateAddHTLC o_conv;
19630         o_conv.inner = (void*)(o & (~1));
19631         o_conv.is_owned = (o & 1) || (o == 0);
19632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19633         o_conv = UpdateAddHTLC_clone(&o_conv);
19634         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19635         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19636         return (uint32_t)ret_conv;
19637 }
19638
19639 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
19640         LDKDecodeError e_conv;
19641         e_conv.inner = (void*)(e & (~1));
19642         e_conv.is_owned = (e & 1) || (e == 0);
19643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19644         e_conv = DecodeError_clone(&e_conv);
19645         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19646         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19647         return (uint32_t)ret_conv;
19648 }
19649
19650 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
19651         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
19652         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19653         return ret_conv;
19654 }
19655
19656 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
19657         if ((_res & 1) != 0) return;
19658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19659         CHECK_ACCESS(_res_ptr);
19660         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19661         FREE((void*)_res);
19662         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19663 }
19664
19665 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19666         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19667         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19668         return (uint32_t)ret_conv;
19669 }
19670 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19671         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
19672         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19673         return ret_conv;
19674 }
19675
19676 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
19677         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
19678         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19679         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19680         return (uint32_t)ret_conv;
19681 }
19682
19683 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
19684         LDKPing o_conv;
19685         o_conv.inner = (void*)(o & (~1));
19686         o_conv.is_owned = (o & 1) || (o == 0);
19687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19688         o_conv = Ping_clone(&o_conv);
19689         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19690         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19691         return (uint32_t)ret_conv;
19692 }
19693
19694 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
19695         LDKDecodeError e_conv;
19696         e_conv.inner = (void*)(e & (~1));
19697         e_conv.is_owned = (e & 1) || (e == 0);
19698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19699         e_conv = DecodeError_clone(&e_conv);
19700         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19701         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19702         return (uint32_t)ret_conv;
19703 }
19704
19705 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
19706         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19707         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19708         return ret_conv;
19709 }
19710
19711 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
19712         if ((_res & 1) != 0) return;
19713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19714         CHECK_ACCESS(_res_ptr);
19715         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19716         FREE((void*)_res);
19717         CResult_PingDecodeErrorZ_free(_res_conv);
19718 }
19719
19720 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19721         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19722         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19723         return (uint32_t)ret_conv;
19724 }
19725 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19726         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19727         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19728         return ret_conv;
19729 }
19730
19731 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19732         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19733         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19734         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19735         return (uint32_t)ret_conv;
19736 }
19737
19738 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19739         LDKPong o_conv;
19740         o_conv.inner = (void*)(o & (~1));
19741         o_conv.is_owned = (o & 1) || (o == 0);
19742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19743         o_conv = Pong_clone(&o_conv);
19744         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19745         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19746         return (uint32_t)ret_conv;
19747 }
19748
19749 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19750         LDKDecodeError e_conv;
19751         e_conv.inner = (void*)(e & (~1));
19752         e_conv.is_owned = (e & 1) || (e == 0);
19753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19754         e_conv = DecodeError_clone(&e_conv);
19755         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19756         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19757         return (uint32_t)ret_conv;
19758 }
19759
19760 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19761         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19762         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19763         return ret_conv;
19764 }
19765
19766 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19767         if ((_res & 1) != 0) return;
19768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19769         CHECK_ACCESS(_res_ptr);
19770         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19771         FREE((void*)_res);
19772         CResult_PongDecodeErrorZ_free(_res_conv);
19773 }
19774
19775 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19776         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19777         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19778         return (uint32_t)ret_conv;
19779 }
19780 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19781         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19782         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19783         return ret_conv;
19784 }
19785
19786 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19787         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19788         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19789         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19790         return (uint32_t)ret_conv;
19791 }
19792
19793 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19794         LDKUnsignedChannelAnnouncement o_conv;
19795         o_conv.inner = (void*)(o & (~1));
19796         o_conv.is_owned = (o & 1) || (o == 0);
19797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19798         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19799         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19800         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19801         return (uint32_t)ret_conv;
19802 }
19803
19804 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19805         LDKDecodeError e_conv;
19806         e_conv.inner = (void*)(e & (~1));
19807         e_conv.is_owned = (e & 1) || (e == 0);
19808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19809         e_conv = DecodeError_clone(&e_conv);
19810         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19811         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19812         return (uint32_t)ret_conv;
19813 }
19814
19815 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19816         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19817         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19818         return ret_conv;
19819 }
19820
19821 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19822         if ((_res & 1) != 0) return;
19823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19824         CHECK_ACCESS(_res_ptr);
19825         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19826         FREE((void*)_res);
19827         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19828 }
19829
19830 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19831         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19832         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19833         return (uint32_t)ret_conv;
19834 }
19835 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19836         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19837         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19838         return ret_conv;
19839 }
19840
19841 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19842         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19843         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19844         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19845         return (uint32_t)ret_conv;
19846 }
19847
19848 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19849         LDKChannelAnnouncement o_conv;
19850         o_conv.inner = (void*)(o & (~1));
19851         o_conv.is_owned = (o & 1) || (o == 0);
19852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19853         o_conv = ChannelAnnouncement_clone(&o_conv);
19854         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19855         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19856         return (uint32_t)ret_conv;
19857 }
19858
19859 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19860         LDKDecodeError e_conv;
19861         e_conv.inner = (void*)(e & (~1));
19862         e_conv.is_owned = (e & 1) || (e == 0);
19863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19864         e_conv = DecodeError_clone(&e_conv);
19865         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19866         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19867         return (uint32_t)ret_conv;
19868 }
19869
19870 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19871         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19872         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19873         return ret_conv;
19874 }
19875
19876 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19877         if ((_res & 1) != 0) return;
19878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19879         CHECK_ACCESS(_res_ptr);
19880         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19881         FREE((void*)_res);
19882         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19883 }
19884
19885 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19886         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19887         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19888         return (uint32_t)ret_conv;
19889 }
19890 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19891         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19892         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19893         return ret_conv;
19894 }
19895
19896 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19897         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19898         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19899         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19900         return (uint32_t)ret_conv;
19901 }
19902
19903 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19904         LDKUnsignedChannelUpdate o_conv;
19905         o_conv.inner = (void*)(o & (~1));
19906         o_conv.is_owned = (o & 1) || (o == 0);
19907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19908         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19909         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19910         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19911         return (uint32_t)ret_conv;
19912 }
19913
19914 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19915         LDKDecodeError e_conv;
19916         e_conv.inner = (void*)(e & (~1));
19917         e_conv.is_owned = (e & 1) || (e == 0);
19918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19919         e_conv = DecodeError_clone(&e_conv);
19920         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19921         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19922         return (uint32_t)ret_conv;
19923 }
19924
19925 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19926         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19927         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19928         return ret_conv;
19929 }
19930
19931 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19932         if ((_res & 1) != 0) return;
19933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19934         CHECK_ACCESS(_res_ptr);
19935         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19936         FREE((void*)_res);
19937         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19938 }
19939
19940 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19941         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19942         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19943         return (uint32_t)ret_conv;
19944 }
19945 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19946         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19947         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19948         return ret_conv;
19949 }
19950
19951 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19952         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19953         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19954         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19955         return (uint32_t)ret_conv;
19956 }
19957
19958 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19959         LDKChannelUpdate o_conv;
19960         o_conv.inner = (void*)(o & (~1));
19961         o_conv.is_owned = (o & 1) || (o == 0);
19962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19963         o_conv = ChannelUpdate_clone(&o_conv);
19964         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19965         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19966         return (uint32_t)ret_conv;
19967 }
19968
19969 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19970         LDKDecodeError e_conv;
19971         e_conv.inner = (void*)(e & (~1));
19972         e_conv.is_owned = (e & 1) || (e == 0);
19973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19974         e_conv = DecodeError_clone(&e_conv);
19975         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19976         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19977         return (uint32_t)ret_conv;
19978 }
19979
19980 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19981         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19982         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19983         return ret_conv;
19984 }
19985
19986 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19987         if ((_res & 1) != 0) return;
19988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19989         CHECK_ACCESS(_res_ptr);
19990         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19991         FREE((void*)_res);
19992         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19993 }
19994
19995 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19996         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19997         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19998         return (uint32_t)ret_conv;
19999 }
20000 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
20001         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
20002         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20003         return ret_conv;
20004 }
20005
20006 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
20007         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
20008         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20009         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
20010         return (uint32_t)ret_conv;
20011 }
20012
20013 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
20014         LDKErrorMessage o_conv;
20015         o_conv.inner = (void*)(o & (~1));
20016         o_conv.is_owned = (o & 1) || (o == 0);
20017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20018         o_conv = ErrorMessage_clone(&o_conv);
20019         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20020         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
20021         return (uint32_t)ret_conv;
20022 }
20023
20024 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
20025         LDKDecodeError e_conv;
20026         e_conv.inner = (void*)(e & (~1));
20027         e_conv.is_owned = (e & 1) || (e == 0);
20028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20029         e_conv = DecodeError_clone(&e_conv);
20030         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20031         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
20032         return (uint32_t)ret_conv;
20033 }
20034
20035 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
20036         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
20037         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
20038         return ret_conv;
20039 }
20040
20041 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
20042         if ((_res & 1) != 0) return;
20043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20044         CHECK_ACCESS(_res_ptr);
20045         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
20046         FREE((void*)_res);
20047         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
20048 }
20049
20050 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
20051         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20052         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
20053         return (uint32_t)ret_conv;
20054 }
20055 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20056         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
20057         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
20058         return ret_conv;
20059 }
20060
20061 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
20062         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
20063         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20064         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
20065         return (uint32_t)ret_conv;
20066 }
20067
20068 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
20069         LDKWarningMessage o_conv;
20070         o_conv.inner = (void*)(o & (~1));
20071         o_conv.is_owned = (o & 1) || (o == 0);
20072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20073         o_conv = WarningMessage_clone(&o_conv);
20074         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20075         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
20076         return (uint32_t)ret_conv;
20077 }
20078
20079 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
20080         LDKDecodeError e_conv;
20081         e_conv.inner = (void*)(e & (~1));
20082         e_conv.is_owned = (e & 1) || (e == 0);
20083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20084         e_conv = DecodeError_clone(&e_conv);
20085         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20086         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
20087         return (uint32_t)ret_conv;
20088 }
20089
20090 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
20091         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
20092         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
20093         return ret_conv;
20094 }
20095
20096 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
20097         if ((_res & 1) != 0) return;
20098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20099         CHECK_ACCESS(_res_ptr);
20100         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
20101         FREE((void*)_res);
20102         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
20103 }
20104
20105 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
20106         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20107         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
20108         return (uint32_t)ret_conv;
20109 }
20110 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20111         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
20112         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
20113         return ret_conv;
20114 }
20115
20116 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
20117         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
20118         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20119         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
20120         return (uint32_t)ret_conv;
20121 }
20122
20123 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20124         LDKUnsignedNodeAnnouncement o_conv;
20125         o_conv.inner = (void*)(o & (~1));
20126         o_conv.is_owned = (o & 1) || (o == 0);
20127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20128         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
20129         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20130         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
20131         return (uint32_t)ret_conv;
20132 }
20133
20134 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20135         LDKDecodeError e_conv;
20136         e_conv.inner = (void*)(e & (~1));
20137         e_conv.is_owned = (e & 1) || (e == 0);
20138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20139         e_conv = DecodeError_clone(&e_conv);
20140         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20141         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
20142         return (uint32_t)ret_conv;
20143 }
20144
20145 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20146         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
20147         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20148         return ret_conv;
20149 }
20150
20151 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20152         if ((_res & 1) != 0) return;
20153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20154         CHECK_ACCESS(_res_ptr);
20155         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
20156         FREE((void*)_res);
20157         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
20158 }
20159
20160 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20161         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20162         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
20163         return (uint32_t)ret_conv;
20164 }
20165 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20166         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
20167         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20168         return ret_conv;
20169 }
20170
20171 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20172         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
20173         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20174         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
20175         return (uint32_t)ret_conv;
20176 }
20177
20178 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20179         LDKNodeAnnouncement o_conv;
20180         o_conv.inner = (void*)(o & (~1));
20181         o_conv.is_owned = (o & 1) || (o == 0);
20182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20183         o_conv = NodeAnnouncement_clone(&o_conv);
20184         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20185         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
20186         return (uint32_t)ret_conv;
20187 }
20188
20189 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20190         LDKDecodeError e_conv;
20191         e_conv.inner = (void*)(e & (~1));
20192         e_conv.is_owned = (e & 1) || (e == 0);
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20194         e_conv = DecodeError_clone(&e_conv);
20195         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20196         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
20197         return (uint32_t)ret_conv;
20198 }
20199
20200 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20201         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
20202         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20203         return ret_conv;
20204 }
20205
20206 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20207         if ((_res & 1) != 0) return;
20208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20209         CHECK_ACCESS(_res_ptr);
20210         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
20211         FREE((void*)_res);
20212         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
20213 }
20214
20215 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20216         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20217         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
20218         return (uint32_t)ret_conv;
20219 }
20220 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20221         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
20222         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20223         return ret_conv;
20224 }
20225
20226 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20227         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
20228         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20229         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
20230         return (uint32_t)ret_conv;
20231 }
20232
20233 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
20234         LDKQueryShortChannelIds o_conv;
20235         o_conv.inner = (void*)(o & (~1));
20236         o_conv.is_owned = (o & 1) || (o == 0);
20237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20238         o_conv = QueryShortChannelIds_clone(&o_conv);
20239         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20240         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
20241         return (uint32_t)ret_conv;
20242 }
20243
20244 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
20245         LDKDecodeError e_conv;
20246         e_conv.inner = (void*)(e & (~1));
20247         e_conv.is_owned = (e & 1) || (e == 0);
20248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20249         e_conv = DecodeError_clone(&e_conv);
20250         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20251         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
20252         return (uint32_t)ret_conv;
20253 }
20254
20255 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
20256         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
20257         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
20258         return ret_conv;
20259 }
20260
20261 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
20262         if ((_res & 1) != 0) return;
20263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20264         CHECK_ACCESS(_res_ptr);
20265         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
20266         FREE((void*)_res);
20267         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
20268 }
20269
20270 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
20271         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20272         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
20273         return (uint32_t)ret_conv;
20274 }
20275 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
20276         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
20277         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
20278         return ret_conv;
20279 }
20280
20281 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
20282         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
20283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20284         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
20285         return (uint32_t)ret_conv;
20286 }
20287
20288 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
20289         LDKReplyShortChannelIdsEnd o_conv;
20290         o_conv.inner = (void*)(o & (~1));
20291         o_conv.is_owned = (o & 1) || (o == 0);
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20293         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
20294         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20295         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
20296         return (uint32_t)ret_conv;
20297 }
20298
20299 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
20300         LDKDecodeError e_conv;
20301         e_conv.inner = (void*)(e & (~1));
20302         e_conv.is_owned = (e & 1) || (e == 0);
20303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20304         e_conv = DecodeError_clone(&e_conv);
20305         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20306         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
20307         return (uint32_t)ret_conv;
20308 }
20309
20310 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
20311         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
20312         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
20313         return ret_conv;
20314 }
20315
20316 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
20317         if ((_res & 1) != 0) return;
20318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20319         CHECK_ACCESS(_res_ptr);
20320         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
20321         FREE((void*)_res);
20322         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
20323 }
20324
20325 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
20326         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20327         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
20328         return (uint32_t)ret_conv;
20329 }
20330 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
20331         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
20332         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
20333         return ret_conv;
20334 }
20335
20336 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
20337         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
20338         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20339         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
20340         return (uint32_t)ret_conv;
20341 }
20342
20343 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
20344         LDKQueryChannelRange o_conv;
20345         o_conv.inner = (void*)(o & (~1));
20346         o_conv.is_owned = (o & 1) || (o == 0);
20347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20348         o_conv = QueryChannelRange_clone(&o_conv);
20349         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20350         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
20351         return (uint32_t)ret_conv;
20352 }
20353
20354 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
20355         LDKDecodeError e_conv;
20356         e_conv.inner = (void*)(e & (~1));
20357         e_conv.is_owned = (e & 1) || (e == 0);
20358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20359         e_conv = DecodeError_clone(&e_conv);
20360         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20361         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
20362         return (uint32_t)ret_conv;
20363 }
20364
20365 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20366         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
20367         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
20368         return ret_conv;
20369 }
20370
20371 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
20372         if ((_res & 1) != 0) return;
20373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20374         CHECK_ACCESS(_res_ptr);
20375         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
20376         FREE((void*)_res);
20377         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
20378 }
20379
20380 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20381         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20382         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
20383         return (uint32_t)ret_conv;
20384 }
20385 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20386         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
20387         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20388         return ret_conv;
20389 }
20390
20391 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20392         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
20393         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20394         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20395         return (uint32_t)ret_conv;
20396 }
20397
20398 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
20399         LDKReplyChannelRange o_conv;
20400         o_conv.inner = (void*)(o & (~1));
20401         o_conv.is_owned = (o & 1) || (o == 0);
20402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20403         o_conv = ReplyChannelRange_clone(&o_conv);
20404         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20405         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20406         return (uint32_t)ret_conv;
20407 }
20408
20409 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
20410         LDKDecodeError e_conv;
20411         e_conv.inner = (void*)(e & (~1));
20412         e_conv.is_owned = (e & 1) || (e == 0);
20413         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20414         e_conv = DecodeError_clone(&e_conv);
20415         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20416         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20417         return (uint32_t)ret_conv;
20418 }
20419
20420 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20421         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
20422         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20423         return ret_conv;
20424 }
20425
20426 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
20427         if ((_res & 1) != 0) return;
20428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20429         CHECK_ACCESS(_res_ptr);
20430         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20431         FREE((void*)_res);
20432         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20433 }
20434
20435 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20436         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20437         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20438         return (uint32_t)ret_conv;
20439 }
20440 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20441         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
20442         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20443         return ret_conv;
20444 }
20445
20446 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20447         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
20448         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20449         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20450         return (uint32_t)ret_conv;
20451 }
20452
20453 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
20454         LDKGossipTimestampFilter o_conv;
20455         o_conv.inner = (void*)(o & (~1));
20456         o_conv.is_owned = (o & 1) || (o == 0);
20457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20458         o_conv = GossipTimestampFilter_clone(&o_conv);
20459         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20460         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20461         return (uint32_t)ret_conv;
20462 }
20463
20464 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
20465         LDKDecodeError e_conv;
20466         e_conv.inner = (void*)(e & (~1));
20467         e_conv.is_owned = (e & 1) || (e == 0);
20468         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20469         e_conv = DecodeError_clone(&e_conv);
20470         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20471         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20472         return (uint32_t)ret_conv;
20473 }
20474
20475 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
20476         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
20477         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20478         return ret_conv;
20479 }
20480
20481 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
20482         if ((_res & 1) != 0) return;
20483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20484         CHECK_ACCESS(_res_ptr);
20485         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20486         FREE((void*)_res);
20487         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20488 }
20489
20490 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20491         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20492         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20493         return (uint32_t)ret_conv;
20494 }
20495 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
20496         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
20497         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20498         return ret_conv;
20499 }
20500
20501 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
20502         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
20503         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20504         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20505         return (uint32_t)ret_conv;
20506 }
20507
20508 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
20509         LDKInvoice o_conv;
20510         o_conv.inner = (void*)(o & (~1));
20511         o_conv.is_owned = (o & 1) || (o == 0);
20512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20513         o_conv = Invoice_clone(&o_conv);
20514         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20515         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20516         return (uint32_t)ret_conv;
20517 }
20518
20519 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
20520         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20521         CHECK_ACCESS(e_ptr);
20522         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20523         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
20524         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20525         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20526         return (uint32_t)ret_conv;
20527 }
20528
20529 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
20530         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
20531         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20532         return ret_conv;
20533 }
20534
20535 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
20536         if ((_res & 1) != 0) return;
20537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20538         CHECK_ACCESS(_res_ptr);
20539         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20540         FREE((void*)_res);
20541         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20542 }
20543
20544 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20545         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20546         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20547         return (uint32_t)ret_conv;
20548 }
20549 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
20550         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
20551         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20552         return ret_conv;
20553 }
20554
20555 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
20556         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
20557         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20558         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20559         return (uint32_t)ret_conv;
20560 }
20561
20562 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
20563         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20564         CHECK_ACCESS(o_ptr);
20565         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20566         if (o_conv.free == LDKFilter_JCalls_free) {
20567                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20568                 LDKFilter_JCalls_cloned(&o_conv);
20569         }
20570         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20571         *ret_copy = COption_FilterZ_some(o_conv);
20572         uint32_t ret_ref = (uintptr_t)ret_copy;
20573         return ret_ref;
20574 }
20575
20576 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20577         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20578         *ret_copy = COption_FilterZ_none();
20579         uint32_t ret_ref = (uintptr_t)ret_copy;
20580         return ret_ref;
20581 }
20582
20583 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
20584         if ((_res & 1) != 0) return;
20585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20586         CHECK_ACCESS(_res_ptr);
20587         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20588         FREE((void*)_res);
20589         COption_FilterZ_free(_res_conv);
20590 }
20591
20592 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
20593         LDKLockedChannelMonitor o_conv;
20594         o_conv.inner = (void*)(o & (~1));
20595         o_conv.is_owned = (o & 1) || (o == 0);
20596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20597         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20598         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20599         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20600         return (uint32_t)ret_conv;
20601 }
20602
20603 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20604         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20605         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20606         return (uint32_t)ret_conv;
20607 }
20608
20609 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
20610         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
20611         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20612         return ret_conv;
20613 }
20614
20615 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
20616         if ((_res & 1) != 0) return;
20617         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20618         CHECK_ACCESS(_res_ptr);
20619         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20620         FREE((void*)_res);
20621         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20622 }
20623
20624 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
20625         LDKCVec_OutPointZ _res_constr;
20626         _res_constr.datalen = _res->arr_len;
20627         if (_res_constr.datalen > 0)
20628                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20629         else
20630                 _res_constr.data = NULL;
20631         uint32_t* _res_vals = _res->elems;
20632         for (size_t k = 0; k < _res_constr.datalen; k++) {
20633                 uint32_t _res_conv_10 = _res_vals[k];
20634                 LDKOutPoint _res_conv_10_conv;
20635                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
20636                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
20637                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20638                 _res_constr.data[k] = _res_conv_10_conv;
20639         }
20640         FREE(_res);
20641         CVec_OutPointZ_free(_res_constr);
20642 }
20643
20644 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
20645         if ((this_ptr & 1) != 0) return;
20646         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20647         CHECK_ACCESS(this_ptr_ptr);
20648         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20649         FREE((void*)this_ptr);
20650         PaymentPurpose_free(this_ptr_conv);
20651 }
20652
20653 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20654         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20655         *ret_copy = PaymentPurpose_clone(arg);
20656 uint32_t ret_ref = (uintptr_t)ret_copy;
20657         return ret_ref;
20658 }
20659 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
20660         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
20661         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20662         return ret_conv;
20663 }
20664
20665 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
20666         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
20667         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20668         *ret_copy = PaymentPurpose_clone(orig_conv);
20669         uint32_t ret_ref = (uintptr_t)ret_copy;
20670         return ret_ref;
20671 }
20672
20673 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20674         LDKThirtyTwoBytes payment_preimage_ref;
20675         CHECK(payment_preimage->arr_len == 32);
20676         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20677         LDKThirtyTwoBytes payment_secret_ref;
20678         CHECK(payment_secret->arr_len == 32);
20679         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20680         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20681         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20682         uint32_t ret_ref = (uintptr_t)ret_copy;
20683         return ret_ref;
20684 }
20685
20686 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20687         LDKThirtyTwoBytes a_ref;
20688         CHECK(a->arr_len == 32);
20689         memcpy(a_ref.data, a->elems, 32); FREE(a);
20690         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20691         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20692         uint32_t ret_ref = (uintptr_t)ret_copy;
20693         return ret_ref;
20694 }
20695
20696 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
20697         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
20698         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20701         CVec_u8Z_free(ret_var);
20702         return ret_arr;
20703 }
20704
20705 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20706         LDKu8slice ser_ref;
20707         ser_ref.datalen = ser->arr_len;
20708         ser_ref.data = ser->elems;
20709         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20710         *ret_conv = PaymentPurpose_read(ser_ref);
20711         FREE(ser);
20712         return (uint32_t)ret_conv;
20713 }
20714
20715 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
20716         if ((this_ptr & 1) != 0) return;
20717         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20718         CHECK_ACCESS(this_ptr_ptr);
20719         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20720         FREE((void*)this_ptr);
20721         ClosureReason_free(this_ptr_conv);
20722 }
20723
20724 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20725         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20726         *ret_copy = ClosureReason_clone(arg);
20727 uint32_t ret_ref = (uintptr_t)ret_copy;
20728         return ret_ref;
20729 }
20730 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20731         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20732         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20733         return ret_conv;
20734 }
20735
20736 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20737         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20738         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20739         *ret_copy = ClosureReason_clone(orig_conv);
20740         uint32_t ret_ref = (uintptr_t)ret_copy;
20741         return ret_ref;
20742 }
20743
20744 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20745         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20746         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20747         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20748         uint32_t ret_ref = (uintptr_t)ret_copy;
20749         return ret_ref;
20750 }
20751
20752 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20753         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20754         *ret_copy = ClosureReason_holder_force_closed();
20755         uint32_t ret_ref = (uintptr_t)ret_copy;
20756         return ret_ref;
20757 }
20758
20759 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20760         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20761         *ret_copy = ClosureReason_cooperative_closure();
20762         uint32_t ret_ref = (uintptr_t)ret_copy;
20763         return ret_ref;
20764 }
20765
20766 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20767         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20768         *ret_copy = ClosureReason_commitment_tx_confirmed();
20769         uint32_t ret_ref = (uintptr_t)ret_copy;
20770         return ret_ref;
20771 }
20772
20773 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20774         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20775         *ret_copy = ClosureReason_funding_timed_out();
20776         uint32_t ret_ref = (uintptr_t)ret_copy;
20777         return ret_ref;
20778 }
20779
20780 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20781         LDKStr err_conv = str_ref_to_owned_c(err);
20782         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20783         *ret_copy = ClosureReason_processing_error(err_conv);
20784         uint32_t ret_ref = (uintptr_t)ret_copy;
20785         return ret_ref;
20786 }
20787
20788 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20789         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20790         *ret_copy = ClosureReason_disconnected_peer();
20791         uint32_t ret_ref = (uintptr_t)ret_copy;
20792         return ret_ref;
20793 }
20794
20795 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20796         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20797         *ret_copy = ClosureReason_outdated_channel_manager();
20798         uint32_t ret_ref = (uintptr_t)ret_copy;
20799         return ret_ref;
20800 }
20801
20802 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20803         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20804         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20807         CVec_u8Z_free(ret_var);
20808         return ret_arr;
20809 }
20810
20811 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20812         LDKu8slice ser_ref;
20813         ser_ref.datalen = ser->arr_len;
20814         ser_ref.data = ser->elems;
20815         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20816         *ret_conv = ClosureReason_read(ser_ref);
20817         FREE(ser);
20818         return (uint32_t)ret_conv;
20819 }
20820
20821 void  __attribute__((export_name("TS_HTLCDestination_free"))) TS_HTLCDestination_free(uint32_t this_ptr) {
20822         if ((this_ptr & 1) != 0) return;
20823         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20824         CHECK_ACCESS(this_ptr_ptr);
20825         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
20826         FREE((void*)this_ptr);
20827         HTLCDestination_free(this_ptr_conv);
20828 }
20829
20830 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
20831         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20832         *ret_copy = HTLCDestination_clone(arg);
20833 uint32_t ret_ref = (uintptr_t)ret_copy;
20834         return ret_ref;
20835 }
20836 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone_ptr"))) TS_HTLCDestination_clone_ptr(uint32_t arg) {
20837         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
20838         uint32_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
20839         return ret_conv;
20840 }
20841
20842 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone"))) TS_HTLCDestination_clone(uint32_t orig) {
20843         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
20844         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20845         *ret_copy = HTLCDestination_clone(orig_conv);
20846         uint32_t ret_ref = (uintptr_t)ret_copy;
20847         return ret_ref;
20848 }
20849
20850 uint32_t  __attribute__((export_name("TS_HTLCDestination_next_hop_channel"))) TS_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
20851         LDKPublicKey node_id_ref;
20852         CHECK(node_id->arr_len == 33);
20853         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20854         LDKThirtyTwoBytes channel_id_ref;
20855         CHECK(channel_id->arr_len == 32);
20856         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20857         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20858         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
20859         uint32_t ret_ref = (uintptr_t)ret_copy;
20860         return ret_ref;
20861 }
20862
20863 uint32_t  __attribute__((export_name("TS_HTLCDestination_unknown_next_hop"))) TS_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
20864         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20865         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
20866         uint32_t ret_ref = (uintptr_t)ret_copy;
20867         return ret_ref;
20868 }
20869
20870 uint32_t  __attribute__((export_name("TS_HTLCDestination_failed_payment"))) TS_HTLCDestination_failed_payment(int8_tArray payment_hash) {
20871         LDKThirtyTwoBytes payment_hash_ref;
20872         CHECK(payment_hash->arr_len == 32);
20873         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20874         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20875         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
20876         uint32_t ret_ref = (uintptr_t)ret_copy;
20877         return ret_ref;
20878 }
20879
20880 int8_tArray  __attribute__((export_name("TS_HTLCDestination_write"))) TS_HTLCDestination_write(uint32_t obj) {
20881         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
20882         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
20883         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20884         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20885         CVec_u8Z_free(ret_var);
20886         return ret_arr;
20887 }
20888
20889 uint32_t  __attribute__((export_name("TS_HTLCDestination_read"))) TS_HTLCDestination_read(int8_tArray ser) {
20890         LDKu8slice ser_ref;
20891         ser_ref.datalen = ser->arr_len;
20892         ser_ref.data = ser->elems;
20893         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
20894         *ret_conv = HTLCDestination_read(ser_ref);
20895         FREE(ser);
20896         return (uint32_t)ret_conv;
20897 }
20898
20899 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20900         if ((this_ptr & 1) != 0) return;
20901         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20902         CHECK_ACCESS(this_ptr_ptr);
20903         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20904         FREE((void*)this_ptr);
20905         Event_free(this_ptr_conv);
20906 }
20907
20908 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20909         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20910         *ret_copy = Event_clone(arg);
20911 uint32_t ret_ref = (uintptr_t)ret_copy;
20912         return ret_ref;
20913 }
20914 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20915         LDKEvent* arg_conv = (LDKEvent*)arg;
20916         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20917         return ret_conv;
20918 }
20919
20920 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20921         LDKEvent* orig_conv = (LDKEvent*)orig;
20922         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20923         *ret_copy = Event_clone(orig_conv);
20924         uint32_t ret_ref = (uintptr_t)ret_copy;
20925         return ret_ref;
20926 }
20927
20928 uint32_t  __attribute__((export_name("TS_Event_funding_generation_ready"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
20929         LDKThirtyTwoBytes temporary_channel_id_ref;
20930         CHECK(temporary_channel_id->arr_len == 32);
20931         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20932         LDKPublicKey counterparty_node_id_ref;
20933         CHECK(counterparty_node_id->arr_len == 33);
20934         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20935         LDKCVec_u8Z output_script_ref;
20936         output_script_ref.datalen = output_script->arr_len;
20937         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20938         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20939         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20940         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20941         uint32_t ret_ref = (uintptr_t)ret_copy;
20942         return ret_ref;
20943 }
20944
20945 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20946         LDKThirtyTwoBytes payment_hash_ref;
20947         CHECK(payment_hash->arr_len == 32);
20948         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20949         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20950         CHECK_ACCESS(purpose_ptr);
20951         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20952         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20953         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20954         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20955         uint32_t ret_ref = (uintptr_t)ret_copy;
20956         return ret_ref;
20957 }
20958
20959 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20960         LDKThirtyTwoBytes payment_hash_ref;
20961         CHECK(payment_hash->arr_len == 32);
20962         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20963         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20964         CHECK_ACCESS(purpose_ptr);
20965         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20966         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20967         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20968         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20969         uint32_t ret_ref = (uintptr_t)ret_copy;
20970         return ret_ref;
20971 }
20972
20973 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) {
20974         LDKThirtyTwoBytes payment_id_ref;
20975         CHECK(payment_id->arr_len == 32);
20976         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20977         LDKThirtyTwoBytes payment_preimage_ref;
20978         CHECK(payment_preimage->arr_len == 32);
20979         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20980         LDKThirtyTwoBytes payment_hash_ref;
20981         CHECK(payment_hash->arr_len == 32);
20982         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20983         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20984         CHECK_ACCESS(fee_paid_msat_ptr);
20985         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20986         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20987         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20988         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20989         uint32_t ret_ref = (uintptr_t)ret_copy;
20990         return ret_ref;
20991 }
20992
20993 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20994         LDKThirtyTwoBytes payment_id_ref;
20995         CHECK(payment_id->arr_len == 32);
20996         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20997         LDKThirtyTwoBytes payment_hash_ref;
20998         CHECK(payment_hash->arr_len == 32);
20999         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21000         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21001         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
21002         uint32_t ret_ref = (uintptr_t)ret_copy;
21003         return ret_ref;
21004 }
21005
21006 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) {
21007         LDKThirtyTwoBytes payment_id_ref;
21008         CHECK(payment_id->arr_len == 32);
21009         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21010         LDKThirtyTwoBytes payment_hash_ref;
21011         CHECK(payment_hash->arr_len == 32);
21012         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21013         LDKCVec_RouteHopZ path_constr;
21014         path_constr.datalen = path->arr_len;
21015         if (path_constr.datalen > 0)
21016                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21017         else
21018                 path_constr.data = NULL;
21019         uint32_t* path_vals = path->elems;
21020         for (size_t k = 0; k < path_constr.datalen; k++) {
21021                 uint32_t path_conv_10 = path_vals[k];
21022                 LDKRouteHop path_conv_10_conv;
21023                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21024                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21025                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21026                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21027                 path_constr.data[k] = path_conv_10_conv;
21028         }
21029         FREE(path);
21030         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21031         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
21032         uint32_t ret_ref = (uintptr_t)ret_copy;
21033         return ret_ref;
21034 }
21035
21036 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) {
21037         LDKThirtyTwoBytes payment_id_ref;
21038         CHECK(payment_id->arr_len == 32);
21039         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21040         LDKThirtyTwoBytes payment_hash_ref;
21041         CHECK(payment_hash->arr_len == 32);
21042         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21043         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
21044         CHECK_ACCESS(network_update_ptr);
21045         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
21046         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
21047         LDKCVec_RouteHopZ path_constr;
21048         path_constr.datalen = path->arr_len;
21049         if (path_constr.datalen > 0)
21050                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21051         else
21052                 path_constr.data = NULL;
21053         uint32_t* path_vals = path->elems;
21054         for (size_t k = 0; k < path_constr.datalen; k++) {
21055                 uint32_t path_conv_10 = path_vals[k];
21056                 LDKRouteHop path_conv_10_conv;
21057                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21058                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21059                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21060                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21061                 path_constr.data[k] = path_conv_10_conv;
21062         }
21063         FREE(path);
21064         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21065         CHECK_ACCESS(short_channel_id_ptr);
21066         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21067         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21068         LDKRouteParameters retry_conv;
21069         retry_conv.inner = (void*)(retry & (~1));
21070         retry_conv.is_owned = (retry & 1) || (retry == 0);
21071         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
21072         retry_conv = RouteParameters_clone(&retry_conv);
21073         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21074         *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);
21075         uint32_t ret_ref = (uintptr_t)ret_copy;
21076         return ret_ref;
21077 }
21078
21079 uint32_t  __attribute__((export_name("TS_Event_probe_successful"))) TS_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path) {
21080         LDKThirtyTwoBytes payment_id_ref;
21081         CHECK(payment_id->arr_len == 32);
21082         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21083         LDKThirtyTwoBytes payment_hash_ref;
21084         CHECK(payment_hash->arr_len == 32);
21085         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21086         LDKCVec_RouteHopZ path_constr;
21087         path_constr.datalen = path->arr_len;
21088         if (path_constr.datalen > 0)
21089                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21090         else
21091                 path_constr.data = NULL;
21092         uint32_t* path_vals = path->elems;
21093         for (size_t k = 0; k < path_constr.datalen; k++) {
21094                 uint32_t path_conv_10 = path_vals[k];
21095                 LDKRouteHop path_conv_10_conv;
21096                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21097                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21098                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21099                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21100                 path_constr.data[k] = path_conv_10_conv;
21101         }
21102         FREE(path);
21103         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21104         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
21105         uint32_t ret_ref = (uintptr_t)ret_copy;
21106         return ret_ref;
21107 }
21108
21109 uint32_t  __attribute__((export_name("TS_Event_probe_failed"))) TS_Event_probe_failed(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path, uint32_t short_channel_id) {
21110         LDKThirtyTwoBytes payment_id_ref;
21111         CHECK(payment_id->arr_len == 32);
21112         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21113         LDKThirtyTwoBytes payment_hash_ref;
21114         CHECK(payment_hash->arr_len == 32);
21115         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21116         LDKCVec_RouteHopZ path_constr;
21117         path_constr.datalen = path->arr_len;
21118         if (path_constr.datalen > 0)
21119                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21120         else
21121                 path_constr.data = NULL;
21122         uint32_t* path_vals = path->elems;
21123         for (size_t k = 0; k < path_constr.datalen; k++) {
21124                 uint32_t path_conv_10 = path_vals[k];
21125                 LDKRouteHop path_conv_10_conv;
21126                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21127                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21128                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21129                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21130                 path_constr.data[k] = path_conv_10_conv;
21131         }
21132         FREE(path);
21133         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21134         CHECK_ACCESS(short_channel_id_ptr);
21135         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21136         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21137         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21138         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
21139         uint32_t ret_ref = (uintptr_t)ret_copy;
21140         return ret_ref;
21141 }
21142
21143 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
21144         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21145         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
21146         uint32_t ret_ref = (uintptr_t)ret_copy;
21147         return ret_ref;
21148 }
21149
21150 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
21151         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
21152         outputs_constr.datalen = outputs->arr_len;
21153         if (outputs_constr.datalen > 0)
21154                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
21155         else
21156                 outputs_constr.data = NULL;
21157         uint32_t* outputs_vals = outputs->elems;
21158         for (size_t b = 0; b < outputs_constr.datalen; b++) {
21159                 uint32_t outputs_conv_27 = outputs_vals[b];
21160                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
21161                 CHECK_ACCESS(outputs_conv_27_ptr);
21162                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
21163                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
21164                 outputs_constr.data[b] = outputs_conv_27_conv;
21165         }
21166         FREE(outputs);
21167         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21168         *ret_copy = Event_spendable_outputs(outputs_constr);
21169         uint32_t ret_ref = (uintptr_t)ret_copy;
21170         return ret_ref;
21171 }
21172
21173 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(int8_tArray prev_channel_id, int8_tArray next_channel_id, uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
21174         LDKThirtyTwoBytes prev_channel_id_ref;
21175         CHECK(prev_channel_id->arr_len == 32);
21176         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21177         LDKThirtyTwoBytes next_channel_id_ref;
21178         CHECK(next_channel_id->arr_len == 32);
21179         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
21180         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
21181         CHECK_ACCESS(fee_earned_msat_ptr);
21182         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
21183         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
21184         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21185         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
21186         uint32_t ret_ref = (uintptr_t)ret_copy;
21187         return ret_ref;
21188 }
21189
21190 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) {
21191         LDKThirtyTwoBytes channel_id_ref;
21192         CHECK(channel_id->arr_len == 32);
21193         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21194         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
21195         CHECK_ACCESS(reason_ptr);
21196         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
21197         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
21198         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21199         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
21200         uint32_t ret_ref = (uintptr_t)ret_copy;
21201         return ret_ref;
21202 }
21203
21204 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
21205         LDKThirtyTwoBytes channel_id_ref;
21206         CHECK(channel_id->arr_len == 32);
21207         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21208         LDKTransaction transaction_ref;
21209         transaction_ref.datalen = transaction->arr_len;
21210         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
21211         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
21212         transaction_ref.data_is_owned = true;
21213         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21214         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
21215         uint32_t ret_ref = (uintptr_t)ret_copy;
21216         return ret_ref;
21217 }
21218
21219 uint32_t  __attribute__((export_name("TS_Event_open_channel_request"))) TS_Event_open_channel_request(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, uint32_t channel_type) {
21220         LDKThirtyTwoBytes temporary_channel_id_ref;
21221         CHECK(temporary_channel_id->arr_len == 32);
21222         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21223         LDKPublicKey counterparty_node_id_ref;
21224         CHECK(counterparty_node_id->arr_len == 33);
21225         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
21226         LDKChannelTypeFeatures channel_type_conv;
21227         channel_type_conv.inner = (void*)(channel_type & (~1));
21228         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
21229         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
21230         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
21231         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21232         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
21233         uint32_t ret_ref = (uintptr_t)ret_copy;
21234         return ret_ref;
21235 }
21236
21237 uint32_t  __attribute__((export_name("TS_Event_htlchandling_failed"))) TS_Event_htlchandling_failed(int8_tArray prev_channel_id, uint32_t failed_next_destination) {
21238         LDKThirtyTwoBytes prev_channel_id_ref;
21239         CHECK(prev_channel_id->arr_len == 32);
21240         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21241         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
21242         CHECK_ACCESS(failed_next_destination_ptr);
21243         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
21244         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
21245         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21246         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
21247         uint32_t ret_ref = (uintptr_t)ret_copy;
21248         return ret_ref;
21249 }
21250
21251 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
21252         LDKEvent* obj_conv = (LDKEvent*)obj;
21253         LDKCVec_u8Z ret_var = Event_write(obj_conv);
21254         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21255         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21256         CVec_u8Z_free(ret_var);
21257         return ret_arr;
21258 }
21259
21260 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
21261         LDKu8slice ser_ref;
21262         ser_ref.datalen = ser->arr_len;
21263         ser_ref.data = ser->elems;
21264         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
21265         *ret_conv = Event_read(ser_ref);
21266         FREE(ser);
21267         return (uint32_t)ret_conv;
21268 }
21269
21270 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
21271         if ((this_ptr & 1) != 0) return;
21272         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21273         CHECK_ACCESS(this_ptr_ptr);
21274         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
21275         FREE((void*)this_ptr);
21276         MessageSendEvent_free(this_ptr_conv);
21277 }
21278
21279 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
21280         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21281         *ret_copy = MessageSendEvent_clone(arg);
21282 uint32_t ret_ref = (uintptr_t)ret_copy;
21283         return ret_ref;
21284 }
21285 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
21286         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
21287         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
21288         return ret_conv;
21289 }
21290
21291 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
21292         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
21293         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21294         *ret_copy = MessageSendEvent_clone(orig_conv);
21295         uint32_t ret_ref = (uintptr_t)ret_copy;
21296         return ret_ref;
21297 }
21298
21299 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
21300         LDKPublicKey node_id_ref;
21301         CHECK(node_id->arr_len == 33);
21302         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21303         LDKAcceptChannel msg_conv;
21304         msg_conv.inner = (void*)(msg & (~1));
21305         msg_conv.is_owned = (msg & 1) || (msg == 0);
21306         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21307         msg_conv = AcceptChannel_clone(&msg_conv);
21308         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21309         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
21310         uint32_t ret_ref = (uintptr_t)ret_copy;
21311         return ret_ref;
21312 }
21313
21314 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
21315         LDKPublicKey node_id_ref;
21316         CHECK(node_id->arr_len == 33);
21317         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21318         LDKOpenChannel msg_conv;
21319         msg_conv.inner = (void*)(msg & (~1));
21320         msg_conv.is_owned = (msg & 1) || (msg == 0);
21321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21322         msg_conv = OpenChannel_clone(&msg_conv);
21323         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21324         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
21325         uint32_t ret_ref = (uintptr_t)ret_copy;
21326         return ret_ref;
21327 }
21328
21329 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
21330         LDKPublicKey node_id_ref;
21331         CHECK(node_id->arr_len == 33);
21332         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21333         LDKFundingCreated msg_conv;
21334         msg_conv.inner = (void*)(msg & (~1));
21335         msg_conv.is_owned = (msg & 1) || (msg == 0);
21336         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21337         msg_conv = FundingCreated_clone(&msg_conv);
21338         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21339         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
21340         uint32_t ret_ref = (uintptr_t)ret_copy;
21341         return ret_ref;
21342 }
21343
21344 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
21345         LDKPublicKey node_id_ref;
21346         CHECK(node_id->arr_len == 33);
21347         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21348         LDKFundingSigned msg_conv;
21349         msg_conv.inner = (void*)(msg & (~1));
21350         msg_conv.is_owned = (msg & 1) || (msg == 0);
21351         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21352         msg_conv = FundingSigned_clone(&msg_conv);
21353         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21354         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
21355         uint32_t ret_ref = (uintptr_t)ret_copy;
21356         return ret_ref;
21357 }
21358
21359 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
21360         LDKPublicKey node_id_ref;
21361         CHECK(node_id->arr_len == 33);
21362         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21363         LDKChannelReady msg_conv;
21364         msg_conv.inner = (void*)(msg & (~1));
21365         msg_conv.is_owned = (msg & 1) || (msg == 0);
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21367         msg_conv = ChannelReady_clone(&msg_conv);
21368         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21369         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
21370         uint32_t ret_ref = (uintptr_t)ret_copy;
21371         return ret_ref;
21372 }
21373
21374 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
21375         LDKPublicKey node_id_ref;
21376         CHECK(node_id->arr_len == 33);
21377         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21378         LDKAnnouncementSignatures msg_conv;
21379         msg_conv.inner = (void*)(msg & (~1));
21380         msg_conv.is_owned = (msg & 1) || (msg == 0);
21381         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21382         msg_conv = AnnouncementSignatures_clone(&msg_conv);
21383         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21384         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
21385         uint32_t ret_ref = (uintptr_t)ret_copy;
21386         return ret_ref;
21387 }
21388
21389 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
21390         LDKPublicKey node_id_ref;
21391         CHECK(node_id->arr_len == 33);
21392         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21393         LDKCommitmentUpdate updates_conv;
21394         updates_conv.inner = (void*)(updates & (~1));
21395         updates_conv.is_owned = (updates & 1) || (updates == 0);
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21397         updates_conv = CommitmentUpdate_clone(&updates_conv);
21398         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21399         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
21400         uint32_t ret_ref = (uintptr_t)ret_copy;
21401         return ret_ref;
21402 }
21403
21404 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
21405         LDKPublicKey node_id_ref;
21406         CHECK(node_id->arr_len == 33);
21407         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21408         LDKRevokeAndACK msg_conv;
21409         msg_conv.inner = (void*)(msg & (~1));
21410         msg_conv.is_owned = (msg & 1) || (msg == 0);
21411         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21412         msg_conv = RevokeAndACK_clone(&msg_conv);
21413         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21414         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
21415         uint32_t ret_ref = (uintptr_t)ret_copy;
21416         return ret_ref;
21417 }
21418
21419 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
21420         LDKPublicKey node_id_ref;
21421         CHECK(node_id->arr_len == 33);
21422         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21423         LDKClosingSigned msg_conv;
21424         msg_conv.inner = (void*)(msg & (~1));
21425         msg_conv.is_owned = (msg & 1) || (msg == 0);
21426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21427         msg_conv = ClosingSigned_clone(&msg_conv);
21428         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21429         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
21430         uint32_t ret_ref = (uintptr_t)ret_copy;
21431         return ret_ref;
21432 }
21433
21434 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
21435         LDKPublicKey node_id_ref;
21436         CHECK(node_id->arr_len == 33);
21437         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21438         LDKShutdown msg_conv;
21439         msg_conv.inner = (void*)(msg & (~1));
21440         msg_conv.is_owned = (msg & 1) || (msg == 0);
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21442         msg_conv = Shutdown_clone(&msg_conv);
21443         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21444         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
21445         uint32_t ret_ref = (uintptr_t)ret_copy;
21446         return ret_ref;
21447 }
21448
21449 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
21450         LDKPublicKey node_id_ref;
21451         CHECK(node_id->arr_len == 33);
21452         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21453         LDKChannelReestablish msg_conv;
21454         msg_conv.inner = (void*)(msg & (~1));
21455         msg_conv.is_owned = (msg & 1) || (msg == 0);
21456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21457         msg_conv = ChannelReestablish_clone(&msg_conv);
21458         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21459         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
21460         uint32_t ret_ref = (uintptr_t)ret_copy;
21461         return ret_ref;
21462 }
21463
21464 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
21465         LDKChannelAnnouncement msg_conv;
21466         msg_conv.inner = (void*)(msg & (~1));
21467         msg_conv.is_owned = (msg & 1) || (msg == 0);
21468         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21469         msg_conv = ChannelAnnouncement_clone(&msg_conv);
21470         LDKChannelUpdate update_msg_conv;
21471         update_msg_conv.inner = (void*)(update_msg & (~1));
21472         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
21473         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
21474         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
21475         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21476         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
21477         uint32_t ret_ref = (uintptr_t)ret_copy;
21478         return ret_ref;
21479 }
21480
21481 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
21482         LDKNodeAnnouncement msg_conv;
21483         msg_conv.inner = (void*)(msg & (~1));
21484         msg_conv.is_owned = (msg & 1) || (msg == 0);
21485         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21486         msg_conv = NodeAnnouncement_clone(&msg_conv);
21487         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21488         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
21489         uint32_t ret_ref = (uintptr_t)ret_copy;
21490         return ret_ref;
21491 }
21492
21493 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
21494         LDKChannelUpdate msg_conv;
21495         msg_conv.inner = (void*)(msg & (~1));
21496         msg_conv.is_owned = (msg & 1) || (msg == 0);
21497         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21498         msg_conv = ChannelUpdate_clone(&msg_conv);
21499         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21500         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
21501         uint32_t ret_ref = (uintptr_t)ret_copy;
21502         return ret_ref;
21503 }
21504
21505 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
21506         LDKPublicKey node_id_ref;
21507         CHECK(node_id->arr_len == 33);
21508         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21509         LDKChannelUpdate msg_conv;
21510         msg_conv.inner = (void*)(msg & (~1));
21511         msg_conv.is_owned = (msg & 1) || (msg == 0);
21512         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21513         msg_conv = ChannelUpdate_clone(&msg_conv);
21514         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21515         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
21516         uint32_t ret_ref = (uintptr_t)ret_copy;
21517         return ret_ref;
21518 }
21519
21520 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
21521         LDKPublicKey node_id_ref;
21522         CHECK(node_id->arr_len == 33);
21523         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21524         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
21525         CHECK_ACCESS(action_ptr);
21526         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
21527         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
21528         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21529         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
21530         uint32_t ret_ref = (uintptr_t)ret_copy;
21531         return ret_ref;
21532 }
21533
21534 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
21535         LDKPublicKey node_id_ref;
21536         CHECK(node_id->arr_len == 33);
21537         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21538         LDKQueryChannelRange msg_conv;
21539         msg_conv.inner = (void*)(msg & (~1));
21540         msg_conv.is_owned = (msg & 1) || (msg == 0);
21541         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21542         msg_conv = QueryChannelRange_clone(&msg_conv);
21543         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21544         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
21545         uint32_t ret_ref = (uintptr_t)ret_copy;
21546         return ret_ref;
21547 }
21548
21549 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
21550         LDKPublicKey node_id_ref;
21551         CHECK(node_id->arr_len == 33);
21552         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21553         LDKQueryShortChannelIds msg_conv;
21554         msg_conv.inner = (void*)(msg & (~1));
21555         msg_conv.is_owned = (msg & 1) || (msg == 0);
21556         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21557         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21558         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21559         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21560         uint32_t ret_ref = (uintptr_t)ret_copy;
21561         return ret_ref;
21562 }
21563
21564 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
21565         LDKPublicKey node_id_ref;
21566         CHECK(node_id->arr_len == 33);
21567         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21568         LDKReplyChannelRange msg_conv;
21569         msg_conv.inner = (void*)(msg & (~1));
21570         msg_conv.is_owned = (msg & 1) || (msg == 0);
21571         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21572         msg_conv = ReplyChannelRange_clone(&msg_conv);
21573         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21574         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21575         uint32_t ret_ref = (uintptr_t)ret_copy;
21576         return ret_ref;
21577 }
21578
21579 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
21580         LDKPublicKey node_id_ref;
21581         CHECK(node_id->arr_len == 33);
21582         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21583         LDKGossipTimestampFilter msg_conv;
21584         msg_conv.inner = (void*)(msg & (~1));
21585         msg_conv.is_owned = (msg & 1) || (msg == 0);
21586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21587         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21588         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21589         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21590         uint32_t ret_ref = (uintptr_t)ret_copy;
21591         return ret_ref;
21592 }
21593
21594 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
21595         if ((this_ptr & 1) != 0) return;
21596         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21597         CHECK_ACCESS(this_ptr_ptr);
21598         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21599         FREE((void*)this_ptr);
21600         MessageSendEventsProvider_free(this_ptr_conv);
21601 }
21602
21603 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
21604         if ((this_ptr & 1) != 0) return;
21605         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21606         CHECK_ACCESS(this_ptr_ptr);
21607         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21608         FREE((void*)this_ptr);
21609         EventsProvider_free(this_ptr_conv);
21610 }
21611
21612 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
21613         if ((this_ptr & 1) != 0) return;
21614         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21615         CHECK_ACCESS(this_ptr_ptr);
21616         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21617         FREE((void*)this_ptr);
21618         EventHandler_free(this_ptr_conv);
21619 }
21620
21621 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
21622         if ((this_ptr & 1) != 0) return;
21623         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21624         CHECK_ACCESS(this_ptr_ptr);
21625         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21626         FREE((void*)this_ptr);
21627         APIError_free(this_ptr_conv);
21628 }
21629
21630 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21631         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21632         *ret_copy = APIError_clone(arg);
21633 uint32_t ret_ref = (uintptr_t)ret_copy;
21634         return ret_ref;
21635 }
21636 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
21637         LDKAPIError* arg_conv = (LDKAPIError*)arg;
21638         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
21639         return ret_conv;
21640 }
21641
21642 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
21643         LDKAPIError* orig_conv = (LDKAPIError*)orig;
21644         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21645         *ret_copy = APIError_clone(orig_conv);
21646         uint32_t ret_ref = (uintptr_t)ret_copy;
21647         return ret_ref;
21648 }
21649
21650 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21651         LDKStr err_conv = str_ref_to_owned_c(err);
21652         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21653         *ret_copy = APIError_apimisuse_error(err_conv);
21654         uint32_t ret_ref = (uintptr_t)ret_copy;
21655         return ret_ref;
21656 }
21657
21658 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21659         LDKStr err_conv = str_ref_to_owned_c(err);
21660         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21661         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21662         uint32_t ret_ref = (uintptr_t)ret_copy;
21663         return ret_ref;
21664 }
21665
21666 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21667         LDKStr err_conv = str_ref_to_owned_c(err);
21668         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21669         *ret_copy = APIError_route_error(err_conv);
21670         uint32_t ret_ref = (uintptr_t)ret_copy;
21671         return ret_ref;
21672 }
21673
21674 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21675         LDKStr err_conv = str_ref_to_owned_c(err);
21676         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21677         *ret_copy = APIError_channel_unavailable(err_conv);
21678         uint32_t ret_ref = (uintptr_t)ret_copy;
21679         return ret_ref;
21680 }
21681
21682 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21683         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21684         *ret_copy = APIError_monitor_update_failed();
21685         uint32_t ret_ref = (uintptr_t)ret_copy;
21686         return ret_ref;
21687 }
21688
21689 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
21690         LDKShutdownScript script_conv;
21691         script_conv.inner = (void*)(script & (~1));
21692         script_conv.is_owned = (script & 1) || (script == 0);
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21694         script_conv = ShutdownScript_clone(&script_conv);
21695         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21696         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21697         uint32_t ret_ref = (uintptr_t)ret_copy;
21698         return ret_ref;
21699 }
21700
21701 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
21702         LDKBigSize this_obj_conv;
21703         this_obj_conv.inner = (void*)(this_obj & (~1));
21704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21706         BigSize_free(this_obj_conv);
21707 }
21708
21709 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
21710         LDKBigSize this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21714         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21715         return ret_conv;
21716 }
21717
21718 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
21719         LDKBigSize this_ptr_conv;
21720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21721         this_ptr_conv.is_owned = false;
21722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21723         BigSize_set_a(&this_ptr_conv, val);
21724 }
21725
21726 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21727         LDKBigSize ret_var = BigSize_new(a_arg);
21728         uint32_t ret_ref = 0;
21729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21732         ret_ref = (uintptr_t)ret_var.inner;
21733         if (ret_var.is_owned) {
21734                 ret_ref |= 1;
21735         }
21736         return ret_ref;
21737 }
21738
21739 void  __attribute__((export_name("TS_Hostname_free"))) TS_Hostname_free(uint32_t this_obj) {
21740         LDKHostname this_obj_conv;
21741         this_obj_conv.inner = (void*)(this_obj & (~1));
21742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21744         Hostname_free(this_obj_conv);
21745 }
21746
21747 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
21748         LDKHostname ret_var = Hostname_clone(arg);
21749 uint32_t ret_ref = 0;
21750 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21751 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21752 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21753 ret_ref = (uintptr_t)ret_var.inner;
21754 if (ret_var.is_owned) {
21755         ret_ref |= 1;
21756 }
21757         return ret_ref;
21758 }
21759 uint32_t  __attribute__((export_name("TS_Hostname_clone_ptr"))) TS_Hostname_clone_ptr(uint32_t arg) {
21760         LDKHostname arg_conv;
21761         arg_conv.inner = (void*)(arg & (~1));
21762         arg_conv.is_owned = false;
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21764         uint32_t ret_conv = Hostname_clone_ptr(&arg_conv);
21765         return ret_conv;
21766 }
21767
21768 uint32_t  __attribute__((export_name("TS_Hostname_clone"))) TS_Hostname_clone(uint32_t orig) {
21769         LDKHostname orig_conv;
21770         orig_conv.inner = (void*)(orig & (~1));
21771         orig_conv.is_owned = false;
21772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21773         LDKHostname ret_var = Hostname_clone(&orig_conv);
21774         uint32_t ret_ref = 0;
21775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21778         ret_ref = (uintptr_t)ret_var.inner;
21779         if (ret_var.is_owned) {
21780                 ret_ref |= 1;
21781         }
21782         return ret_ref;
21783 }
21784
21785 int8_t  __attribute__((export_name("TS_Hostname_len"))) TS_Hostname_len(uint32_t this_arg) {
21786         LDKHostname this_arg_conv;
21787         this_arg_conv.inner = (void*)(this_arg & (~1));
21788         this_arg_conv.is_owned = false;
21789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21790         int8_t ret_conv = Hostname_len(&this_arg_conv);
21791         return ret_conv;
21792 }
21793
21794 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21795         LDKu8slice msg_ref;
21796         msg_ref.datalen = msg->arr_len;
21797         msg_ref.data = msg->elems;
21798         unsigned char sk_arr[32];
21799         CHECK(sk->arr_len == 32);
21800         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21801         unsigned char (*sk_ref)[32] = &sk_arr;
21802         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21803         *ret_conv = sign(msg_ref, sk_ref);
21804         FREE(msg);
21805         return (uint32_t)ret_conv;
21806 }
21807
21808 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21809         LDKu8slice msg_ref;
21810         msg_ref.datalen = msg->arr_len;
21811         msg_ref.data = msg->elems;
21812         LDKStr sig_conv = str_ref_to_owned_c(sig);
21813         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21814         *ret_conv = recover_pk(msg_ref, sig_conv);
21815         FREE(msg);
21816         return (uint32_t)ret_conv;
21817 }
21818
21819 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21820         LDKu8slice msg_ref;
21821         msg_ref.datalen = msg->arr_len;
21822         msg_ref.data = msg->elems;
21823         LDKStr sig_conv = str_ref_to_owned_c(sig);
21824         LDKPublicKey pk_ref;
21825         CHECK(pk->arr_len == 33);
21826         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21827         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21828         FREE(msg);
21829         return ret_conv;
21830 }
21831
21832 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21833         LDKu8slice hrp_bytes_ref;
21834         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21835         hrp_bytes_ref.data = hrp_bytes->elems;
21836         LDKCVec_u5Z data_without_signature_constr;
21837         data_without_signature_constr.datalen = data_without_signature->arr_len;
21838         if (data_without_signature_constr.datalen > 0)
21839                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21840         else
21841                 data_without_signature_constr.data = NULL;
21842         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21843         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21844                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21845                 
21846                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21847         }
21848         FREE(data_without_signature);
21849         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21852         CVec_u8Z_free(ret_var);
21853         FREE(hrp_bytes);
21854         return ret_arr;
21855 }
21856
21857 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
21858         if ((this_ptr & 1) != 0) return;
21859         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21860         CHECK_ACCESS(this_ptr_ptr);
21861         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21862         FREE((void*)this_ptr);
21863         Persister_free(this_ptr_conv);
21864 }
21865
21866 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
21867         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
21868         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21869         return ret_conv;
21870 }
21871
21872 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21873         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21874         return ret_conv;
21875 }
21876
21877 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21878         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21879         return ret_conv;
21880 }
21881
21882 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21883         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21884         return ret_conv;
21885 }
21886
21887 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21888         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21889         return ret_conv;
21890 }
21891
21892 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21893         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21894         return ret_conv;
21895 }
21896
21897 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21898         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21899         return ret_conv;
21900 }
21901
21902 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
21903         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
21904         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
21905         jboolean ret_conv = Level_eq(a_conv, b_conv);
21906         return ret_conv;
21907 }
21908
21909 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
21910         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
21911         int64_t ret_conv = Level_hash(o_conv);
21912         return ret_conv;
21913 }
21914
21915 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21916         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21917         return ret_conv;
21918 }
21919
21920 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
21921         LDKRecord this_obj_conv;
21922         this_obj_conv.inner = (void*)(this_obj & (~1));
21923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21925         Record_free(this_obj_conv);
21926 }
21927
21928 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
21929         LDKRecord this_ptr_conv;
21930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21931         this_ptr_conv.is_owned = false;
21932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21933         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
21934         return ret_conv;
21935 }
21936
21937 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
21938         LDKRecord this_ptr_conv;
21939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21940         this_ptr_conv.is_owned = false;
21941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21942         LDKLevel val_conv = LDKLevel_from_js(val);
21943         Record_set_level(&this_ptr_conv, val_conv);
21944 }
21945
21946 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
21947         LDKRecord this_ptr_conv;
21948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21949         this_ptr_conv.is_owned = false;
21950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21951         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21952         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21953         Str_free(ret_str);
21954         return ret_conv;
21955 }
21956
21957 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21958         LDKRecord this_ptr_conv;
21959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21960         this_ptr_conv.is_owned = false;
21961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21962         LDKStr val_conv = str_ref_to_owned_c(val);
21963         Record_set_args(&this_ptr_conv, val_conv);
21964 }
21965
21966 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21967         LDKRecord this_ptr_conv;
21968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21969         this_ptr_conv.is_owned = false;
21970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21971         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21972         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21973         Str_free(ret_str);
21974         return ret_conv;
21975 }
21976
21977 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21978         LDKRecord this_ptr_conv;
21979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21980         this_ptr_conv.is_owned = false;
21981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21982         LDKStr val_conv = str_ref_to_owned_c(val);
21983         Record_set_module_path(&this_ptr_conv, val_conv);
21984 }
21985
21986 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21987         LDKRecord this_ptr_conv;
21988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21989         this_ptr_conv.is_owned = false;
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21991         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21992         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21993         Str_free(ret_str);
21994         return ret_conv;
21995 }
21996
21997 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
21998         LDKRecord this_ptr_conv;
21999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22000         this_ptr_conv.is_owned = false;
22001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22002         LDKStr val_conv = str_ref_to_owned_c(val);
22003         Record_set_file(&this_ptr_conv, val_conv);
22004 }
22005
22006 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
22007         LDKRecord this_ptr_conv;
22008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22009         this_ptr_conv.is_owned = false;
22010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22011         int32_t ret_conv = Record_get_line(&this_ptr_conv);
22012         return ret_conv;
22013 }
22014
22015 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
22016         LDKRecord this_ptr_conv;
22017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22018         this_ptr_conv.is_owned = false;
22019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22020         Record_set_line(&this_ptr_conv, val);
22021 }
22022
22023 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
22024         LDKRecord ret_var = Record_clone(arg);
22025 uint32_t ret_ref = 0;
22026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22029 ret_ref = (uintptr_t)ret_var.inner;
22030 if (ret_var.is_owned) {
22031         ret_ref |= 1;
22032 }
22033         return ret_ref;
22034 }
22035 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
22036         LDKRecord arg_conv;
22037         arg_conv.inner = (void*)(arg & (~1));
22038         arg_conv.is_owned = false;
22039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22040         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
22041         return ret_conv;
22042 }
22043
22044 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
22045         LDKRecord orig_conv;
22046         orig_conv.inner = (void*)(orig & (~1));
22047         orig_conv.is_owned = false;
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22049         LDKRecord ret_var = Record_clone(&orig_conv);
22050         uint32_t ret_ref = 0;
22051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22054         ret_ref = (uintptr_t)ret_var.inner;
22055         if (ret_var.is_owned) {
22056                 ret_ref |= 1;
22057         }
22058         return ret_ref;
22059 }
22060
22061 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
22062         if ((this_ptr & 1) != 0) return;
22063         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22064         CHECK_ACCESS(this_ptr_ptr);
22065         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
22066         FREE((void*)this_ptr);
22067         Logger_free(this_ptr_conv);
22068 }
22069
22070 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
22071         LDKChannelHandshakeConfig this_obj_conv;
22072         this_obj_conv.inner = (void*)(this_obj & (~1));
22073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22075         ChannelHandshakeConfig_free(this_obj_conv);
22076 }
22077
22078 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
22079         LDKChannelHandshakeConfig this_ptr_conv;
22080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22081         this_ptr_conv.is_owned = false;
22082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22083         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
22084         return ret_conv;
22085 }
22086
22087 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
22088         LDKChannelHandshakeConfig this_ptr_conv;
22089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22090         this_ptr_conv.is_owned = false;
22091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22092         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
22093 }
22094
22095 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
22096         LDKChannelHandshakeConfig this_ptr_conv;
22097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22098         this_ptr_conv.is_owned = false;
22099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22100         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
22101         return ret_conv;
22102 }
22103
22104 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) {
22105         LDKChannelHandshakeConfig this_ptr_conv;
22106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22107         this_ptr_conv.is_owned = false;
22108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22109         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
22110 }
22111
22112 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
22113         LDKChannelHandshakeConfig this_ptr_conv;
22114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22115         this_ptr_conv.is_owned = false;
22116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22117         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
22118         return ret_conv;
22119 }
22120
22121 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) {
22122         LDKChannelHandshakeConfig this_ptr_conv;
22123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22124         this_ptr_conv.is_owned = false;
22125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22126         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
22127 }
22128
22129 int8_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel"))) TS_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(uint32_t this_ptr) {
22130         LDKChannelHandshakeConfig this_ptr_conv;
22131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22132         this_ptr_conv.is_owned = false;
22133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22134         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
22135         return ret_conv;
22136 }
22137
22138 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel"))) TS_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(uint32_t this_ptr, int8_t val) {
22139         LDKChannelHandshakeConfig this_ptr_conv;
22140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22141         this_ptr_conv.is_owned = false;
22142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22143         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
22144 }
22145
22146 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
22147         LDKChannelHandshakeConfig this_ptr_conv;
22148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22149         this_ptr_conv.is_owned = false;
22150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22151         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
22152         return ret_conv;
22153 }
22154
22155 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
22156         LDKChannelHandshakeConfig this_ptr_conv;
22157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22158         this_ptr_conv.is_owned = false;
22159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22160         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
22161 }
22162
22163 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint32_t this_ptr) {
22164         LDKChannelHandshakeConfig this_ptr_conv;
22165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22166         this_ptr_conv.is_owned = false;
22167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22168         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
22169         return ret_conv;
22170 }
22171
22172 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
22173         LDKChannelHandshakeConfig this_ptr_conv;
22174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22175         this_ptr_conv.is_owned = false;
22176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22177         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
22178 }
22179
22180 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
22181         LDKChannelHandshakeConfig this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22185         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
22186         return ret_conv;
22187 }
22188
22189 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
22190         LDKChannelHandshakeConfig this_ptr_conv;
22191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22192         this_ptr_conv.is_owned = false;
22193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22194         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
22195 }
22196
22197 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, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
22198         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
22199         uint32_t ret_ref = 0;
22200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22203         ret_ref = (uintptr_t)ret_var.inner;
22204         if (ret_var.is_owned) {
22205                 ret_ref |= 1;
22206         }
22207         return ret_ref;
22208 }
22209
22210 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
22211         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
22212 uint32_t ret_ref = 0;
22213 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22214 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22216 ret_ref = (uintptr_t)ret_var.inner;
22217 if (ret_var.is_owned) {
22218         ret_ref |= 1;
22219 }
22220         return ret_ref;
22221 }
22222 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
22223         LDKChannelHandshakeConfig arg_conv;
22224         arg_conv.inner = (void*)(arg & (~1));
22225         arg_conv.is_owned = false;
22226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22227         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
22228         return ret_conv;
22229 }
22230
22231 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
22232         LDKChannelHandshakeConfig orig_conv;
22233         orig_conv.inner = (void*)(orig & (~1));
22234         orig_conv.is_owned = false;
22235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22236         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
22237         uint32_t ret_ref = 0;
22238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22241         ret_ref = (uintptr_t)ret_var.inner;
22242         if (ret_var.is_owned) {
22243                 ret_ref |= 1;
22244         }
22245         return ret_ref;
22246 }
22247
22248 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
22249         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
22250         uint32_t ret_ref = 0;
22251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22254         ret_ref = (uintptr_t)ret_var.inner;
22255         if (ret_var.is_owned) {
22256                 ret_ref |= 1;
22257         }
22258         return ret_ref;
22259 }
22260
22261 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
22262         LDKChannelHandshakeLimits this_obj_conv;
22263         this_obj_conv.inner = (void*)(this_obj & (~1));
22264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22266         ChannelHandshakeLimits_free(this_obj_conv);
22267 }
22268
22269 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
22270         LDKChannelHandshakeLimits this_ptr_conv;
22271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22272         this_ptr_conv.is_owned = false;
22273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22274         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
22275         return ret_conv;
22276 }
22277
22278 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
22279         LDKChannelHandshakeLimits this_ptr_conv;
22280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22281         this_ptr_conv.is_owned = false;
22282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22283         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
22284 }
22285
22286 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
22287         LDKChannelHandshakeLimits this_ptr_conv;
22288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22289         this_ptr_conv.is_owned = false;
22290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22291         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
22292         return ret_conv;
22293 }
22294
22295 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
22296         LDKChannelHandshakeLimits this_ptr_conv;
22297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22298         this_ptr_conv.is_owned = false;
22299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22300         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
22301 }
22302
22303 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
22304         LDKChannelHandshakeLimits this_ptr_conv;
22305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22306         this_ptr_conv.is_owned = false;
22307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22308         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
22309         return ret_conv;
22310 }
22311
22312 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) {
22313         LDKChannelHandshakeLimits this_ptr_conv;
22314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22315         this_ptr_conv.is_owned = false;
22316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22317         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
22318 }
22319
22320 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) {
22321         LDKChannelHandshakeLimits this_ptr_conv;
22322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22323         this_ptr_conv.is_owned = false;
22324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22325         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
22326         return ret_conv;
22327 }
22328
22329 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) {
22330         LDKChannelHandshakeLimits this_ptr_conv;
22331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22332         this_ptr_conv.is_owned = false;
22333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22334         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22335 }
22336
22337 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
22338         LDKChannelHandshakeLimits this_ptr_conv;
22339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22340         this_ptr_conv.is_owned = false;
22341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22342         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
22343         return ret_conv;
22344 }
22345
22346 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) {
22347         LDKChannelHandshakeLimits this_ptr_conv;
22348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22349         this_ptr_conv.is_owned = false;
22350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22351         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
22352 }
22353
22354 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
22355         LDKChannelHandshakeLimits this_ptr_conv;
22356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22357         this_ptr_conv.is_owned = false;
22358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22359         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
22360         return ret_conv;
22361 }
22362
22363 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) {
22364         LDKChannelHandshakeLimits this_ptr_conv;
22365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22366         this_ptr_conv.is_owned = false;
22367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22368         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
22369 }
22370
22371 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
22372         LDKChannelHandshakeLimits this_ptr_conv;
22373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22374         this_ptr_conv.is_owned = false;
22375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22376         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
22377         return ret_conv;
22378 }
22379
22380 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
22381         LDKChannelHandshakeLimits 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         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
22386 }
22387
22388 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
22389         LDKChannelHandshakeLimits this_ptr_conv;
22390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22391         this_ptr_conv.is_owned = false;
22392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22393         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
22394         return ret_conv;
22395 }
22396
22397 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
22398         LDKChannelHandshakeLimits this_ptr_conv;
22399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22400         this_ptr_conv.is_owned = false;
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22402         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
22403 }
22404
22405 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
22406         LDKChannelHandshakeLimits this_ptr_conv;
22407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22408         this_ptr_conv.is_owned = false;
22409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22410         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
22411         return ret_conv;
22412 }
22413
22414 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
22415         LDKChannelHandshakeLimits this_ptr_conv;
22416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22417         this_ptr_conv.is_owned = false;
22418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22419         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
22420 }
22421
22422 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
22423         LDKChannelHandshakeLimits this_ptr_conv;
22424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22425         this_ptr_conv.is_owned = false;
22426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22427         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
22428         return ret_conv;
22429 }
22430
22431 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) {
22432         LDKChannelHandshakeLimits this_ptr_conv;
22433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22434         this_ptr_conv.is_owned = false;
22435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22436         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
22437 }
22438
22439 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_new"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_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 trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
22440         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_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, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
22441         uint32_t ret_ref = 0;
22442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22445         ret_ref = (uintptr_t)ret_var.inner;
22446         if (ret_var.is_owned) {
22447                 ret_ref |= 1;
22448         }
22449         return ret_ref;
22450 }
22451
22452 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
22453         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
22454 uint32_t ret_ref = 0;
22455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22458 ret_ref = (uintptr_t)ret_var.inner;
22459 if (ret_var.is_owned) {
22460         ret_ref |= 1;
22461 }
22462         return ret_ref;
22463 }
22464 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
22465         LDKChannelHandshakeLimits arg_conv;
22466         arg_conv.inner = (void*)(arg & (~1));
22467         arg_conv.is_owned = false;
22468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22469         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
22470         return ret_conv;
22471 }
22472
22473 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
22474         LDKChannelHandshakeLimits orig_conv;
22475         orig_conv.inner = (void*)(orig & (~1));
22476         orig_conv.is_owned = false;
22477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22478         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
22479         uint32_t ret_ref = 0;
22480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22483         ret_ref = (uintptr_t)ret_var.inner;
22484         if (ret_var.is_owned) {
22485                 ret_ref |= 1;
22486         }
22487         return ret_ref;
22488 }
22489
22490 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
22491         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
22492         uint32_t ret_ref = 0;
22493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22496         ret_ref = (uintptr_t)ret_var.inner;
22497         if (ret_var.is_owned) {
22498                 ret_ref |= 1;
22499         }
22500         return ret_ref;
22501 }
22502
22503 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
22504         LDKChannelConfig this_obj_conv;
22505         this_obj_conv.inner = (void*)(this_obj & (~1));
22506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22508         ChannelConfig_free(this_obj_conv);
22509 }
22510
22511 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
22512         LDKChannelConfig this_ptr_conv;
22513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22514         this_ptr_conv.is_owned = false;
22515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22516         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
22517         return ret_conv;
22518 }
22519
22520 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) {
22521         LDKChannelConfig this_ptr_conv;
22522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22523         this_ptr_conv.is_owned = false;
22524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22525         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
22526 }
22527
22528 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
22529         LDKChannelConfig this_ptr_conv;
22530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22531         this_ptr_conv.is_owned = false;
22532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22533         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
22534         return ret_conv;
22535 }
22536
22537 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) {
22538         LDKChannelConfig this_ptr_conv;
22539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22540         this_ptr_conv.is_owned = false;
22541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22542         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
22543 }
22544
22545 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
22546         LDKChannelConfig this_ptr_conv;
22547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22548         this_ptr_conv.is_owned = false;
22549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22550         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
22551         return ret_conv;
22552 }
22553
22554 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
22555         LDKChannelConfig this_ptr_conv;
22556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22557         this_ptr_conv.is_owned = false;
22558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22559         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
22560 }
22561
22562 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) {
22563         LDKChannelConfig this_ptr_conv;
22564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22565         this_ptr_conv.is_owned = false;
22566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22567         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
22568         return ret_conv;
22569 }
22570
22571 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) {
22572         LDKChannelConfig this_ptr_conv;
22573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22574         this_ptr_conv.is_owned = false;
22575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22576         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
22577 }
22578
22579 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) {
22580         LDKChannelConfig this_ptr_conv;
22581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22582         this_ptr_conv.is_owned = false;
22583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22584         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
22585         return ret_conv;
22586 }
22587
22588 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) {
22589         LDKChannelConfig this_ptr_conv;
22590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22591         this_ptr_conv.is_owned = false;
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22593         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
22594 }
22595
22596 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, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
22597         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
22598         uint32_t ret_ref = 0;
22599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22602         ret_ref = (uintptr_t)ret_var.inner;
22603         if (ret_var.is_owned) {
22604                 ret_ref |= 1;
22605         }
22606         return ret_ref;
22607 }
22608
22609 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22610         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22611 uint32_t ret_ref = 0;
22612 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22613 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22615 ret_ref = (uintptr_t)ret_var.inner;
22616 if (ret_var.is_owned) {
22617         ret_ref |= 1;
22618 }
22619         return ret_ref;
22620 }
22621 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
22622         LDKChannelConfig arg_conv;
22623         arg_conv.inner = (void*)(arg & (~1));
22624         arg_conv.is_owned = false;
22625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22626         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22627         return ret_conv;
22628 }
22629
22630 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
22631         LDKChannelConfig orig_conv;
22632         orig_conv.inner = (void*)(orig & (~1));
22633         orig_conv.is_owned = false;
22634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22635         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22636         uint32_t ret_ref = 0;
22637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22640         ret_ref = (uintptr_t)ret_var.inner;
22641         if (ret_var.is_owned) {
22642                 ret_ref |= 1;
22643         }
22644         return ret_ref;
22645 }
22646
22647 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22648         LDKChannelConfig ret_var = ChannelConfig_default();
22649         uint32_t ret_ref = 0;
22650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22653         ret_ref = (uintptr_t)ret_var.inner;
22654         if (ret_var.is_owned) {
22655                 ret_ref |= 1;
22656         }
22657         return ret_ref;
22658 }
22659
22660 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
22661         LDKChannelConfig obj_conv;
22662         obj_conv.inner = (void*)(obj & (~1));
22663         obj_conv.is_owned = false;
22664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22665         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22668         CVec_u8Z_free(ret_var);
22669         return ret_arr;
22670 }
22671
22672 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22673         LDKu8slice ser_ref;
22674         ser_ref.datalen = ser->arr_len;
22675         ser_ref.data = ser->elems;
22676         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22677         *ret_conv = ChannelConfig_read(ser_ref);
22678         FREE(ser);
22679         return (uint32_t)ret_conv;
22680 }
22681
22682 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
22683         LDKUserConfig this_obj_conv;
22684         this_obj_conv.inner = (void*)(this_obj & (~1));
22685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22687         UserConfig_free(this_obj_conv);
22688 }
22689
22690 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint32_t this_ptr) {
22691         LDKUserConfig this_ptr_conv;
22692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22693         this_ptr_conv.is_owned = false;
22694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22695         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22696         uint32_t ret_ref = 0;
22697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22700         ret_ref = (uintptr_t)ret_var.inner;
22701         if (ret_var.is_owned) {
22702                 ret_ref |= 1;
22703         }
22704         return ret_ref;
22705 }
22706
22707 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint32_t this_ptr, uint32_t val) {
22708         LDKUserConfig this_ptr_conv;
22709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22710         this_ptr_conv.is_owned = false;
22711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22712         LDKChannelHandshakeConfig val_conv;
22713         val_conv.inner = (void*)(val & (~1));
22714         val_conv.is_owned = (val & 1) || (val == 0);
22715         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22716         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22717         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22718 }
22719
22720 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint32_t this_ptr) {
22721         LDKUserConfig this_ptr_conv;
22722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22723         this_ptr_conv.is_owned = false;
22724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22725         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22726         uint32_t ret_ref = 0;
22727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22730         ret_ref = (uintptr_t)ret_var.inner;
22731         if (ret_var.is_owned) {
22732                 ret_ref |= 1;
22733         }
22734         return ret_ref;
22735 }
22736
22737 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint32_t this_ptr, uint32_t val) {
22738         LDKUserConfig this_ptr_conv;
22739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22740         this_ptr_conv.is_owned = false;
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22742         LDKChannelHandshakeLimits val_conv;
22743         val_conv.inner = (void*)(val & (~1));
22744         val_conv.is_owned = (val & 1) || (val == 0);
22745         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22746         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22747         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22748 }
22749
22750 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint32_t this_ptr) {
22751         LDKUserConfig this_ptr_conv;
22752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22753         this_ptr_conv.is_owned = false;
22754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22755         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22756         uint32_t ret_ref = 0;
22757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22760         ret_ref = (uintptr_t)ret_var.inner;
22761         if (ret_var.is_owned) {
22762                 ret_ref |= 1;
22763         }
22764         return ret_ref;
22765 }
22766
22767 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint32_t this_ptr, uint32_t val) {
22768         LDKUserConfig this_ptr_conv;
22769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22770         this_ptr_conv.is_owned = false;
22771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22772         LDKChannelConfig val_conv;
22773         val_conv.inner = (void*)(val & (~1));
22774         val_conv.is_owned = (val & 1) || (val == 0);
22775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22776         val_conv = ChannelConfig_clone(&val_conv);
22777         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22778 }
22779
22780 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
22781         LDKUserConfig this_ptr_conv;
22782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22783         this_ptr_conv.is_owned = false;
22784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22785         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22786         return ret_conv;
22787 }
22788
22789 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) {
22790         LDKUserConfig this_ptr_conv;
22791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22792         this_ptr_conv.is_owned = false;
22793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22794         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22795 }
22796
22797 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
22798         LDKUserConfig this_ptr_conv;
22799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22800         this_ptr_conv.is_owned = false;
22801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22802         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22803         return ret_conv;
22804 }
22805
22806 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22807         LDKUserConfig this_ptr_conv;
22808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22809         this_ptr_conv.is_owned = false;
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22811         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22812 }
22813
22814 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
22815         LDKUserConfig this_ptr_conv;
22816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22817         this_ptr_conv.is_owned = false;
22818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22819         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22820         return ret_conv;
22821 }
22822
22823 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22824         LDKUserConfig 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         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22829 }
22830
22831 uint32_t  __attribute__((export_name("TS_UserConfig_new"))) TS_UserConfig_new(uint32_t channel_handshake_config_arg, uint32_t channel_handshake_limits_arg, uint32_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
22832         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22833         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
22834         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
22835         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22836         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22837         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22838         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
22839         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
22840         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22841         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22842         LDKChannelConfig channel_config_arg_conv;
22843         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
22844         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
22845         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22846         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22847         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
22848         uint32_t ret_ref = 0;
22849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22852         ret_ref = (uintptr_t)ret_var.inner;
22853         if (ret_var.is_owned) {
22854                 ret_ref |= 1;
22855         }
22856         return ret_ref;
22857 }
22858
22859 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22860         LDKUserConfig ret_var = UserConfig_clone(arg);
22861 uint32_t ret_ref = 0;
22862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22865 ret_ref = (uintptr_t)ret_var.inner;
22866 if (ret_var.is_owned) {
22867         ret_ref |= 1;
22868 }
22869         return ret_ref;
22870 }
22871 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
22872         LDKUserConfig arg_conv;
22873         arg_conv.inner = (void*)(arg & (~1));
22874         arg_conv.is_owned = false;
22875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22876         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22877         return ret_conv;
22878 }
22879
22880 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
22881         LDKUserConfig orig_conv;
22882         orig_conv.inner = (void*)(orig & (~1));
22883         orig_conv.is_owned = false;
22884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22885         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22886         uint32_t ret_ref = 0;
22887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22890         ret_ref = (uintptr_t)ret_var.inner;
22891         if (ret_var.is_owned) {
22892                 ret_ref |= 1;
22893         }
22894         return ret_ref;
22895 }
22896
22897 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22898         LDKUserConfig ret_var = UserConfig_default();
22899         uint32_t ret_ref = 0;
22900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22903         ret_ref = (uintptr_t)ret_var.inner;
22904         if (ret_var.is_owned) {
22905                 ret_ref |= 1;
22906         }
22907         return ret_ref;
22908 }
22909
22910 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
22911         LDKBestBlock this_obj_conv;
22912         this_obj_conv.inner = (void*)(this_obj & (~1));
22913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22915         BestBlock_free(this_obj_conv);
22916 }
22917
22918 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22919         LDKBestBlock ret_var = BestBlock_clone(arg);
22920 uint32_t ret_ref = 0;
22921 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22922 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22923 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22924 ret_ref = (uintptr_t)ret_var.inner;
22925 if (ret_var.is_owned) {
22926         ret_ref |= 1;
22927 }
22928         return ret_ref;
22929 }
22930 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
22931         LDKBestBlock arg_conv;
22932         arg_conv.inner = (void*)(arg & (~1));
22933         arg_conv.is_owned = false;
22934         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22935         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22936         return ret_conv;
22937 }
22938
22939 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
22940         LDKBestBlock orig_conv;
22941         orig_conv.inner = (void*)(orig & (~1));
22942         orig_conv.is_owned = false;
22943         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22944         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
22945         uint32_t ret_ref = 0;
22946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22949         ret_ref = (uintptr_t)ret_var.inner;
22950         if (ret_var.is_owned) {
22951                 ret_ref |= 1;
22952         }
22953         return ret_ref;
22954 }
22955
22956 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22957         LDKNetwork network_conv = LDKNetwork_from_js(network);
22958         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22959         uint32_t ret_ref = 0;
22960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22963         ret_ref = (uintptr_t)ret_var.inner;
22964         if (ret_var.is_owned) {
22965                 ret_ref |= 1;
22966         }
22967         return ret_ref;
22968 }
22969
22970 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22971         LDKThirtyTwoBytes block_hash_ref;
22972         CHECK(block_hash->arr_len == 32);
22973         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22974         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22975         uint32_t ret_ref = 0;
22976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22979         ret_ref = (uintptr_t)ret_var.inner;
22980         if (ret_var.is_owned) {
22981                 ret_ref |= 1;
22982         }
22983         return ret_ref;
22984 }
22985
22986 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22987         LDKBestBlock this_arg_conv;
22988         this_arg_conv.inner = (void*)(this_arg & (~1));
22989         this_arg_conv.is_owned = false;
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22991         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22992         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22993         return ret_arr;
22994 }
22995
22996 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22997         LDKBestBlock this_arg_conv;
22998         this_arg_conv.inner = (void*)(this_arg & (~1));
22999         this_arg_conv.is_owned = false;
23000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23001         int32_t ret_conv = BestBlock_height(&this_arg_conv);
23002         return ret_conv;
23003 }
23004
23005 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
23006         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
23007         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
23008         return ret_conv;
23009 }
23010
23011 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
23012         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
23013         return ret_conv;
23014 }
23015
23016 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
23017         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
23018         return ret_conv;
23019 }
23020
23021 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
23022         if ((this_ptr & 1) != 0) return;
23023         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23024         CHECK_ACCESS(this_ptr_ptr);
23025         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
23026         FREE((void*)this_ptr);
23027         Access_free(this_ptr_conv);
23028 }
23029
23030 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
23031         if ((this_ptr & 1) != 0) return;
23032         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23033         CHECK_ACCESS(this_ptr_ptr);
23034         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
23035         FREE((void*)this_ptr);
23036         Listen_free(this_ptr_conv);
23037 }
23038
23039 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
23040         if ((this_ptr & 1) != 0) return;
23041         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23042         CHECK_ACCESS(this_ptr_ptr);
23043         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
23044         FREE((void*)this_ptr);
23045         Confirm_free(this_ptr_conv);
23046 }
23047
23048 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
23049         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
23050         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
23051         return ret_conv;
23052 }
23053
23054 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
23055         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
23056         return ret_conv;
23057 }
23058
23059 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
23060         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
23061         return ret_conv;
23062 }
23063
23064 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
23065         if ((this_ptr & 1) != 0) return;
23066         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23067         CHECK_ACCESS(this_ptr_ptr);
23068         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
23069         FREE((void*)this_ptr);
23070         Watch_free(this_ptr_conv);
23071 }
23072
23073 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
23074         if ((this_ptr & 1) != 0) return;
23075         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23076         CHECK_ACCESS(this_ptr_ptr);
23077         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
23078         FREE((void*)this_ptr);
23079         Filter_free(this_ptr_conv);
23080 }
23081
23082 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
23083         LDKWatchedOutput this_obj_conv;
23084         this_obj_conv.inner = (void*)(this_obj & (~1));
23085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23087         WatchedOutput_free(this_obj_conv);
23088 }
23089
23090 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
23091         LDKWatchedOutput this_ptr_conv;
23092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23093         this_ptr_conv.is_owned = false;
23094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23095         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23096         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
23097         return ret_arr;
23098 }
23099
23100 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
23101         LDKWatchedOutput this_ptr_conv;
23102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23103         this_ptr_conv.is_owned = false;
23104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23105         LDKThirtyTwoBytes val_ref;
23106         CHECK(val->arr_len == 32);
23107         memcpy(val_ref.data, val->elems, 32); FREE(val);
23108         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
23109 }
23110
23111 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
23112         LDKWatchedOutput this_ptr_conv;
23113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23114         this_ptr_conv.is_owned = false;
23115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23116         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
23117         uint32_t ret_ref = 0;
23118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23121         ret_ref = (uintptr_t)ret_var.inner;
23122         if (ret_var.is_owned) {
23123                 ret_ref |= 1;
23124         }
23125         return ret_ref;
23126 }
23127
23128 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
23129         LDKWatchedOutput this_ptr_conv;
23130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23131         this_ptr_conv.is_owned = false;
23132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23133         LDKOutPoint val_conv;
23134         val_conv.inner = (void*)(val & (~1));
23135         val_conv.is_owned = (val & 1) || (val == 0);
23136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23137         val_conv = OutPoint_clone(&val_conv);
23138         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
23139 }
23140
23141 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
23142         LDKWatchedOutput this_ptr_conv;
23143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23144         this_ptr_conv.is_owned = false;
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23146         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
23147         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23148         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23149         return ret_arr;
23150 }
23151
23152 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
23153         LDKWatchedOutput this_ptr_conv;
23154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23155         this_ptr_conv.is_owned = false;
23156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23157         LDKCVec_u8Z val_ref;
23158         val_ref.datalen = val->arr_len;
23159         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23160         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23161         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
23162 }
23163
23164 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) {
23165         LDKThirtyTwoBytes block_hash_arg_ref;
23166         CHECK(block_hash_arg->arr_len == 32);
23167         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
23168         LDKOutPoint outpoint_arg_conv;
23169         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23170         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23171         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23172         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23173         LDKCVec_u8Z script_pubkey_arg_ref;
23174         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
23175         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23176         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
23177         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
23178         uint32_t ret_ref = 0;
23179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23182         ret_ref = (uintptr_t)ret_var.inner;
23183         if (ret_var.is_owned) {
23184                 ret_ref |= 1;
23185         }
23186         return ret_ref;
23187 }
23188
23189 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
23190         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
23191 uint32_t ret_ref = 0;
23192 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23193 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23194 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23195 ret_ref = (uintptr_t)ret_var.inner;
23196 if (ret_var.is_owned) {
23197         ret_ref |= 1;
23198 }
23199         return ret_ref;
23200 }
23201 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
23202         LDKWatchedOutput arg_conv;
23203         arg_conv.inner = (void*)(arg & (~1));
23204         arg_conv.is_owned = false;
23205         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23206         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
23207         return ret_conv;
23208 }
23209
23210 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
23211         LDKWatchedOutput orig_conv;
23212         orig_conv.inner = (void*)(orig & (~1));
23213         orig_conv.is_owned = false;
23214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23215         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
23216         uint32_t ret_ref = 0;
23217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23220         ret_ref = (uintptr_t)ret_var.inner;
23221         if (ret_var.is_owned) {
23222                 ret_ref |= 1;
23223         }
23224         return ret_ref;
23225 }
23226
23227 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
23228         LDKWatchedOutput o_conv;
23229         o_conv.inner = (void*)(o & (~1));
23230         o_conv.is_owned = false;
23231         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23232         int64_t ret_conv = WatchedOutput_hash(&o_conv);
23233         return ret_conv;
23234 }
23235
23236 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
23237         if ((this_ptr & 1) != 0) return;
23238         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23239         CHECK_ACCESS(this_ptr_ptr);
23240         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
23241         FREE((void*)this_ptr);
23242         BroadcasterInterface_free(this_ptr_conv);
23243 }
23244
23245 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
23246         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
23247         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
23248         return ret_conv;
23249 }
23250
23251 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
23252         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
23253         return ret_conv;
23254 }
23255
23256 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
23257         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
23258         return ret_conv;
23259 }
23260
23261 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
23262         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
23263         return ret_conv;
23264 }
23265
23266 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
23267         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
23268         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
23269         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
23270         return ret_conv;
23271 }
23272
23273 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
23274         if ((this_ptr & 1) != 0) return;
23275         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23276         CHECK_ACCESS(this_ptr_ptr);
23277         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
23278         FREE((void*)this_ptr);
23279         FeeEstimator_free(this_ptr_conv);
23280 }
23281
23282 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
23283         LDKMonitorUpdateId this_obj_conv;
23284         this_obj_conv.inner = (void*)(this_obj & (~1));
23285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23287         MonitorUpdateId_free(this_obj_conv);
23288 }
23289
23290 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
23291         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
23292 uint32_t ret_ref = 0;
23293 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23294 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23295 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23296 ret_ref = (uintptr_t)ret_var.inner;
23297 if (ret_var.is_owned) {
23298         ret_ref |= 1;
23299 }
23300         return ret_ref;
23301 }
23302 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
23303         LDKMonitorUpdateId arg_conv;
23304         arg_conv.inner = (void*)(arg & (~1));
23305         arg_conv.is_owned = false;
23306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23307         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
23308         return ret_conv;
23309 }
23310
23311 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
23312         LDKMonitorUpdateId orig_conv;
23313         orig_conv.inner = (void*)(orig & (~1));
23314         orig_conv.is_owned = false;
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23316         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
23317         uint32_t ret_ref = 0;
23318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23321         ret_ref = (uintptr_t)ret_var.inner;
23322         if (ret_var.is_owned) {
23323                 ret_ref |= 1;
23324         }
23325         return ret_ref;
23326 }
23327
23328 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
23329         LDKMonitorUpdateId o_conv;
23330         o_conv.inner = (void*)(o & (~1));
23331         o_conv.is_owned = false;
23332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23333         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
23334         return ret_conv;
23335 }
23336
23337 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
23338         LDKMonitorUpdateId a_conv;
23339         a_conv.inner = (void*)(a & (~1));
23340         a_conv.is_owned = false;
23341         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23342         LDKMonitorUpdateId b_conv;
23343         b_conv.inner = (void*)(b & (~1));
23344         b_conv.is_owned = false;
23345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23346         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
23347         return ret_conv;
23348 }
23349
23350 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
23351         if ((this_ptr & 1) != 0) return;
23352         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23353         CHECK_ACCESS(this_ptr_ptr);
23354         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
23355         FREE((void*)this_ptr);
23356         Persist_free(this_ptr_conv);
23357 }
23358
23359 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
23360         LDKLockedChannelMonitor this_obj_conv;
23361         this_obj_conv.inner = (void*)(this_obj & (~1));
23362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23364         LockedChannelMonitor_free(this_obj_conv);
23365 }
23366
23367 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
23368         LDKChainMonitor this_obj_conv;
23369         this_obj_conv.inner = (void*)(this_obj & (~1));
23370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23372         ChainMonitor_free(this_obj_conv);
23373 }
23374
23375 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) {
23376         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
23377         CHECK_ACCESS(chain_source_ptr);
23378         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
23379         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
23380         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
23381                 // Manually implement clone for Java trait instances
23382                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
23383                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23384                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
23385                 }
23386         }
23387         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23388         CHECK_ACCESS(broadcaster_ptr);
23389         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23390         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23392                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23393         }
23394         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23395         CHECK_ACCESS(logger_ptr);
23396         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23397         if (logger_conv.free == LDKLogger_JCalls_free) {
23398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23399                 LDKLogger_JCalls_cloned(&logger_conv);
23400         }
23401         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
23402         CHECK_ACCESS(feeest_ptr);
23403         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
23404         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
23405                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23406                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
23407         }
23408         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
23409         CHECK_ACCESS(persister_ptr);
23410         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
23411         if (persister_conv.free == LDKPersist_JCalls_free) {
23412                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23413                 LDKPersist_JCalls_cloned(&persister_conv);
23414         }
23415         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
23416         uint32_t ret_ref = 0;
23417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23420         ret_ref = (uintptr_t)ret_var.inner;
23421         if (ret_var.is_owned) {
23422                 ret_ref |= 1;
23423         }
23424         return ret_ref;
23425 }
23426
23427 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
23428         LDKChainMonitor this_arg_conv;
23429         this_arg_conv.inner = (void*)(this_arg & (~1));
23430         this_arg_conv.is_owned = false;
23431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23432         LDKCVec_ChannelDetailsZ ignored_channels_constr;
23433         ignored_channels_constr.datalen = ignored_channels->arr_len;
23434         if (ignored_channels_constr.datalen > 0)
23435                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23436         else
23437                 ignored_channels_constr.data = NULL;
23438         uint32_t* ignored_channels_vals = ignored_channels->elems;
23439         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
23440                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
23441                 LDKChannelDetails ignored_channels_conv_16_conv;
23442                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
23443                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
23444                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
23445                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
23446                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
23447         }
23448         FREE(ignored_channels);
23449         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
23450         uint32_tArray ret_arr = NULL;
23451         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23452         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23453         for (size_t j = 0; j < ret_var.datalen; j++) {
23454                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23455                 *ret_conv_9_copy = ret_var.data[j];
23456                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23457                 ret_arr_ptr[j] = ret_conv_9_ref;
23458         }
23459         
23460         FREE(ret_var.data);
23461         return ret_arr;
23462 }
23463
23464 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
23465         LDKChainMonitor this_arg_conv;
23466         this_arg_conv.inner = (void*)(this_arg & (~1));
23467         this_arg_conv.is_owned = false;
23468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23469         LDKOutPoint funding_txo_conv;
23470         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23471         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23473         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23474         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23475         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
23476         return (uint32_t)ret_conv;
23477 }
23478
23479 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
23480         LDKChainMonitor 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         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
23485         uint32_tArray ret_arr = NULL;
23486         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23487         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23488         for (size_t k = 0; k < ret_var.datalen; k++) {
23489                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
23490                 uint32_t ret_conv_10_ref = 0;
23491                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23492                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23493                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
23494                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
23495                 if (ret_conv_10_var.is_owned) {
23496                         ret_conv_10_ref |= 1;
23497                 }
23498                 ret_arr_ptr[k] = ret_conv_10_ref;
23499         }
23500         
23501         FREE(ret_var.data);
23502         return ret_arr;
23503 }
23504
23505 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) {
23506         LDKChainMonitor this_arg_conv;
23507         this_arg_conv.inner = (void*)(this_arg & (~1));
23508         this_arg_conv.is_owned = false;
23509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23510         LDKOutPoint funding_txo_conv;
23511         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23512         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23513         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23514         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23515         LDKMonitorUpdateId completed_update_id_conv;
23516         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
23517         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
23518         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
23519         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
23520         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
23521         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
23522         return (uint32_t)ret_conv;
23523 }
23524
23525 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
23526         LDKChainMonitor this_arg_conv;
23527         this_arg_conv.inner = (void*)(this_arg & (~1));
23528         this_arg_conv.is_owned = false;
23529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23530         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
23531         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
23532         return (uint32_t)ret_ret;
23533 }
23534
23535 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
23536         LDKChainMonitor this_arg_conv;
23537         this_arg_conv.inner = (void*)(this_arg & (~1));
23538         this_arg_conv.is_owned = false;
23539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23540         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
23541         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
23542         return (uint32_t)ret_ret;
23543 }
23544
23545 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
23546         LDKChainMonitor this_arg_conv;
23547         this_arg_conv.inner = (void*)(this_arg & (~1));
23548         this_arg_conv.is_owned = false;
23549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23550         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
23551         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
23552         return (uint32_t)ret_ret;
23553 }
23554
23555 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
23556         LDKChainMonitor this_arg_conv;
23557         this_arg_conv.inner = (void*)(this_arg & (~1));
23558         this_arg_conv.is_owned = false;
23559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23560         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
23561         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
23562         return (uint32_t)ret_ret;
23563 }
23564
23565 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
23566         LDKChannelMonitorUpdate this_obj_conv;
23567         this_obj_conv.inner = (void*)(this_obj & (~1));
23568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23570         ChannelMonitorUpdate_free(this_obj_conv);
23571 }
23572
23573 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
23574         LDKChannelMonitorUpdate this_ptr_conv;
23575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23576         this_ptr_conv.is_owned = false;
23577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23578         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
23579         return ret_conv;
23580 }
23581
23582 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
23583         LDKChannelMonitorUpdate this_ptr_conv;
23584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23585         this_ptr_conv.is_owned = false;
23586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23587         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
23588 }
23589
23590 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
23591         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
23592 uint32_t ret_ref = 0;
23593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23596 ret_ref = (uintptr_t)ret_var.inner;
23597 if (ret_var.is_owned) {
23598         ret_ref |= 1;
23599 }
23600         return ret_ref;
23601 }
23602 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
23603         LDKChannelMonitorUpdate arg_conv;
23604         arg_conv.inner = (void*)(arg & (~1));
23605         arg_conv.is_owned = false;
23606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23607         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23608         return ret_conv;
23609 }
23610
23611 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
23612         LDKChannelMonitorUpdate orig_conv;
23613         orig_conv.inner = (void*)(orig & (~1));
23614         orig_conv.is_owned = false;
23615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23616         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23617         uint32_t ret_ref = 0;
23618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23621         ret_ref = (uintptr_t)ret_var.inner;
23622         if (ret_var.is_owned) {
23623                 ret_ref |= 1;
23624         }
23625         return ret_ref;
23626 }
23627
23628 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
23629         LDKChannelMonitorUpdate obj_conv;
23630         obj_conv.inner = (void*)(obj & (~1));
23631         obj_conv.is_owned = false;
23632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23633         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23634         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23635         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23636         CVec_u8Z_free(ret_var);
23637         return ret_arr;
23638 }
23639
23640 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23641         LDKu8slice ser_ref;
23642         ser_ref.datalen = ser->arr_len;
23643         ser_ref.data = ser->elems;
23644         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23645         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23646         FREE(ser);
23647         return (uint32_t)ret_conv;
23648 }
23649
23650 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
23651         if ((this_ptr & 1) != 0) return;
23652         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23653         CHECK_ACCESS(this_ptr_ptr);
23654         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23655         FREE((void*)this_ptr);
23656         MonitorEvent_free(this_ptr_conv);
23657 }
23658
23659 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23660         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23661         *ret_copy = MonitorEvent_clone(arg);
23662 uint32_t ret_ref = (uintptr_t)ret_copy;
23663         return ret_ref;
23664 }
23665 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
23666         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
23667         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23668         return ret_conv;
23669 }
23670
23671 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
23672         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
23673         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23674         *ret_copy = MonitorEvent_clone(orig_conv);
23675         uint32_t ret_ref = (uintptr_t)ret_copy;
23676         return ret_ref;
23677 }
23678
23679 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
23680         LDKHTLCUpdate a_conv;
23681         a_conv.inner = (void*)(a & (~1));
23682         a_conv.is_owned = (a & 1) || (a == 0);
23683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23684         a_conv = HTLCUpdate_clone(&a_conv);
23685         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23686         *ret_copy = MonitorEvent_htlcevent(a_conv);
23687         uint32_t ret_ref = (uintptr_t)ret_copy;
23688         return ret_ref;
23689 }
23690
23691 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
23692         LDKOutPoint a_conv;
23693         a_conv.inner = (void*)(a & (~1));
23694         a_conv.is_owned = (a & 1) || (a == 0);
23695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23696         a_conv = OutPoint_clone(&a_conv);
23697         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23698         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23699         uint32_t ret_ref = (uintptr_t)ret_copy;
23700         return ret_ref;
23701 }
23702
23703 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
23704         LDKOutPoint funding_txo_conv;
23705         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23706         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23707         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23708         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23709         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23710         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23711         uint32_t ret_ref = (uintptr_t)ret_copy;
23712         return ret_ref;
23713 }
23714
23715 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
23716         LDKOutPoint a_conv;
23717         a_conv.inner = (void*)(a & (~1));
23718         a_conv.is_owned = (a & 1) || (a == 0);
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23720         a_conv = OutPoint_clone(&a_conv);
23721         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23722         *ret_copy = MonitorEvent_update_failed(a_conv);
23723         uint32_t ret_ref = (uintptr_t)ret_copy;
23724         return ret_ref;
23725 }
23726
23727 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
23728         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
23729         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23730         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23731         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23732         CVec_u8Z_free(ret_var);
23733         return ret_arr;
23734 }
23735
23736 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23737         LDKu8slice ser_ref;
23738         ser_ref.datalen = ser->arr_len;
23739         ser_ref.data = ser->elems;
23740         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23741         *ret_conv = MonitorEvent_read(ser_ref);
23742         FREE(ser);
23743         return (uint32_t)ret_conv;
23744 }
23745
23746 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
23747         LDKHTLCUpdate this_obj_conv;
23748         this_obj_conv.inner = (void*)(this_obj & (~1));
23749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23751         HTLCUpdate_free(this_obj_conv);
23752 }
23753
23754 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23755         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23756 uint32_t ret_ref = 0;
23757 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23758 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23759 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23760 ret_ref = (uintptr_t)ret_var.inner;
23761 if (ret_var.is_owned) {
23762         ret_ref |= 1;
23763 }
23764         return ret_ref;
23765 }
23766 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
23767         LDKHTLCUpdate arg_conv;
23768         arg_conv.inner = (void*)(arg & (~1));
23769         arg_conv.is_owned = false;
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23771         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23772         return ret_conv;
23773 }
23774
23775 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
23776         LDKHTLCUpdate orig_conv;
23777         orig_conv.inner = (void*)(orig & (~1));
23778         orig_conv.is_owned = false;
23779         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23780         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23781         uint32_t ret_ref = 0;
23782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23785         ret_ref = (uintptr_t)ret_var.inner;
23786         if (ret_var.is_owned) {
23787                 ret_ref |= 1;
23788         }
23789         return ret_ref;
23790 }
23791
23792 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
23793         LDKHTLCUpdate obj_conv;
23794         obj_conv.inner = (void*)(obj & (~1));
23795         obj_conv.is_owned = false;
23796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23797         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23798         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23799         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23800         CVec_u8Z_free(ret_var);
23801         return ret_arr;
23802 }
23803
23804 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23805         LDKu8slice ser_ref;
23806         ser_ref.datalen = ser->arr_len;
23807         ser_ref.data = ser->elems;
23808         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23809         *ret_conv = HTLCUpdate_read(ser_ref);
23810         FREE(ser);
23811         return (uint32_t)ret_conv;
23812 }
23813
23814 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
23815         if ((this_ptr & 1) != 0) return;
23816         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23817         CHECK_ACCESS(this_ptr_ptr);
23818         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23819         FREE((void*)this_ptr);
23820         Balance_free(this_ptr_conv);
23821 }
23822
23823 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23824         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23825         *ret_copy = Balance_clone(arg);
23826 uint32_t ret_ref = (uintptr_t)ret_copy;
23827         return ret_ref;
23828 }
23829 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
23830         LDKBalance* arg_conv = (LDKBalance*)arg;
23831         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
23832         return ret_conv;
23833 }
23834
23835 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
23836         LDKBalance* orig_conv = (LDKBalance*)orig;
23837         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23838         *ret_copy = Balance_clone(orig_conv);
23839         uint32_t ret_ref = (uintptr_t)ret_copy;
23840         return ret_ref;
23841 }
23842
23843 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23844         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23845         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23846         uint32_t ret_ref = (uintptr_t)ret_copy;
23847         return ret_ref;
23848 }
23849
23850 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23851         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23852         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23853         uint32_t ret_ref = (uintptr_t)ret_copy;
23854         return ret_ref;
23855 }
23856
23857 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23858         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23859         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23860         uint32_t ret_ref = (uintptr_t)ret_copy;
23861         return ret_ref;
23862 }
23863
23864 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) {
23865         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23866         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
23867         uint32_t ret_ref = (uintptr_t)ret_copy;
23868         return ret_ref;
23869 }
23870
23871 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
23872         LDKBalance* a_conv = (LDKBalance*)a;
23873         LDKBalance* b_conv = (LDKBalance*)b;
23874         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23875         return ret_conv;
23876 }
23877
23878 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
23879         LDKChannelMonitor this_obj_conv;
23880         this_obj_conv.inner = (void*)(this_obj & (~1));
23881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23883         ChannelMonitor_free(this_obj_conv);
23884 }
23885
23886 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23887         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23888 uint32_t ret_ref = 0;
23889 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23890 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23891 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23892 ret_ref = (uintptr_t)ret_var.inner;
23893 if (ret_var.is_owned) {
23894         ret_ref |= 1;
23895 }
23896         return ret_ref;
23897 }
23898 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
23899         LDKChannelMonitor arg_conv;
23900         arg_conv.inner = (void*)(arg & (~1));
23901         arg_conv.is_owned = false;
23902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23903         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23904         return ret_conv;
23905 }
23906
23907 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
23908         LDKChannelMonitor orig_conv;
23909         orig_conv.inner = (void*)(orig & (~1));
23910         orig_conv.is_owned = false;
23911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23912         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23913         uint32_t ret_ref = 0;
23914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23917         ret_ref = (uintptr_t)ret_var.inner;
23918         if (ret_var.is_owned) {
23919                 ret_ref |= 1;
23920         }
23921         return ret_ref;
23922 }
23923
23924 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
23925         LDKChannelMonitor obj_conv;
23926         obj_conv.inner = (void*)(obj & (~1));
23927         obj_conv.is_owned = false;
23928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23929         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23930         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23931         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23932         CVec_u8Z_free(ret_var);
23933         return ret_arr;
23934 }
23935
23936 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) {
23937         LDKChannelMonitor this_arg_conv;
23938         this_arg_conv.inner = (void*)(this_arg & (~1));
23939         this_arg_conv.is_owned = false;
23940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23941         LDKChannelMonitorUpdate updates_conv;
23942         updates_conv.inner = (void*)(updates & (~1));
23943         updates_conv.is_owned = false;
23944         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23945         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23946         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
23947         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23948         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23949         CHECK_ACCESS(fee_estimator_ptr);
23950         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23951         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23952                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23953                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23954         }
23955         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23956         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23957         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23958         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23959         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23960         return (uint32_t)ret_conv;
23961 }
23962
23963 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23964         LDKChannelMonitor this_arg_conv;
23965         this_arg_conv.inner = (void*)(this_arg & (~1));
23966         this_arg_conv.is_owned = false;
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23968         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23969         return ret_conv;
23970 }
23971
23972 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23973         LDKChannelMonitor this_arg_conv;
23974         this_arg_conv.inner = (void*)(this_arg & (~1));
23975         this_arg_conv.is_owned = false;
23976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23977         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23978         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23979         return ((uint32_t)ret_conv);
23980 }
23981
23982 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23983         LDKChannelMonitor this_arg_conv;
23984         this_arg_conv.inner = (void*)(this_arg & (~1));
23985         this_arg_conv.is_owned = false;
23986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23987         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23988         uint32_tArray ret_arr = NULL;
23989         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23990         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23991         for (size_t o = 0; o < ret_var.datalen; o++) {
23992                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23993                 *ret_conv_40_conv = ret_var.data[o];
23994                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23995         }
23996         
23997         FREE(ret_var.data);
23998         return ret_arr;
23999 }
24000
24001 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
24002         LDKChannelMonitor this_arg_conv;
24003         this_arg_conv.inner = (void*)(this_arg & (~1));
24004         this_arg_conv.is_owned = false;
24005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24006         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
24007         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
24008         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
24009         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
24010 }
24011
24012 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) {
24013         LDKChannelMonitor this_arg_conv;
24014         this_arg_conv.inner = (void*)(this_arg & (~1));
24015         this_arg_conv.is_owned = false;
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24017         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
24018         uint32_tArray ret_arr = NULL;
24019         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24020         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24021         for (size_t o = 0; o < ret_var.datalen; o++) {
24022                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24023                 *ret_conv_14_copy = ret_var.data[o];
24024                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
24025                 ret_arr_ptr[o] = ret_conv_14_ref;
24026         }
24027         
24028         FREE(ret_var.data);
24029         return ret_arr;
24030 }
24031
24032 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
24033         LDKChannelMonitor this_arg_conv;
24034         this_arg_conv.inner = (void*)(this_arg & (~1));
24035         this_arg_conv.is_owned = false;
24036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24037         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
24038         uint32_tArray ret_arr = NULL;
24039         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24040         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24041         for (size_t h = 0; h < ret_var.datalen; h++) {
24042                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24043                 *ret_conv_7_copy = ret_var.data[h];
24044                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
24045                 ret_arr_ptr[h] = ret_conv_7_ref;
24046         }
24047         
24048         FREE(ret_var.data);
24049         return ret_arr;
24050 }
24051
24052 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_get_counterparty_node_id"))) TS_ChannelMonitor_get_counterparty_node_id(uint32_t this_arg) {
24053         LDKChannelMonitor this_arg_conv;
24054         this_arg_conv.inner = (void*)(this_arg & (~1));
24055         this_arg_conv.is_owned = false;
24056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24057         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24058         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
24059         return ret_arr;
24060 }
24061
24062 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) {
24063         LDKChannelMonitor this_arg_conv;
24064         this_arg_conv.inner = (void*)(this_arg & (~1));
24065         this_arg_conv.is_owned = false;
24066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24067         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24068         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
24069         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24070         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
24071         ptrArray ret_arr = NULL;
24072         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24073         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
24074         for (size_t m = 0; m < ret_var.datalen; m++) {
24075                 LDKTransaction ret_conv_12_var = ret_var.data[m];
24076                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
24077                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
24078                 Transaction_free(ret_conv_12_var);
24079                 ret_arr_ptr[m] = ret_conv_12_arr;
24080         }
24081         
24082         FREE(ret_var.data);
24083         return ret_arr;
24084 }
24085
24086 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) {
24087         LDKChannelMonitor this_arg_conv;
24088         this_arg_conv.inner = (void*)(this_arg & (~1));
24089         this_arg_conv.is_owned = false;
24090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24091         unsigned char header_arr[80];
24092         CHECK(header->arr_len == 80);
24093         memcpy(header_arr, header->elems, 80); FREE(header);
24094         unsigned char (*header_ref)[80] = &header_arr;
24095         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24096         txdata_constr.datalen = txdata->arr_len;
24097         if (txdata_constr.datalen > 0)
24098                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24099         else
24100                 txdata_constr.data = NULL;
24101         uint32_t* txdata_vals = txdata->elems;
24102         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24103                 uint32_t txdata_conv_28 = txdata_vals[c];
24104                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24105                 CHECK_ACCESS(txdata_conv_28_ptr);
24106                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24107                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24108                 txdata_constr.data[c] = txdata_conv_28_conv;
24109         }
24110         FREE(txdata);
24111         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24112         CHECK_ACCESS(broadcaster_ptr);
24113         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24114         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24116                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24117         }
24118         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24119         CHECK_ACCESS(fee_estimator_ptr);
24120         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24121         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24123                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24124         }
24125         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24126         CHECK_ACCESS(logger_ptr);
24127         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24128         if (logger_conv.free == LDKLogger_JCalls_free) {
24129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24130                 LDKLogger_JCalls_cloned(&logger_conv);
24131         }
24132         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);
24133         uint32_tArray ret_arr = NULL;
24134         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24135         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24136         for (size_t n = 0; n < ret_var.datalen; n++) {
24137                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24138                 *ret_conv_39_conv = ret_var.data[n];
24139                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24140         }
24141         
24142         FREE(ret_var.data);
24143         return ret_arr;
24144 }
24145
24146 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) {
24147         LDKChannelMonitor this_arg_conv;
24148         this_arg_conv.inner = (void*)(this_arg & (~1));
24149         this_arg_conv.is_owned = false;
24150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24151         unsigned char header_arr[80];
24152         CHECK(header->arr_len == 80);
24153         memcpy(header_arr, header->elems, 80); FREE(header);
24154         unsigned char (*header_ref)[80] = &header_arr;
24155         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24156         CHECK_ACCESS(broadcaster_ptr);
24157         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24158         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24159                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24160                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24161         }
24162         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24163         CHECK_ACCESS(fee_estimator_ptr);
24164         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24165         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24166                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24167                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24168         }
24169         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24170         CHECK_ACCESS(logger_ptr);
24171         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24172         if (logger_conv.free == LDKLogger_JCalls_free) {
24173                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24174                 LDKLogger_JCalls_cloned(&logger_conv);
24175         }
24176         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24177 }
24178
24179 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) {
24180         LDKChannelMonitor this_arg_conv;
24181         this_arg_conv.inner = (void*)(this_arg & (~1));
24182         this_arg_conv.is_owned = false;
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24184         unsigned char header_arr[80];
24185         CHECK(header->arr_len == 80);
24186         memcpy(header_arr, header->elems, 80); FREE(header);
24187         unsigned char (*header_ref)[80] = &header_arr;
24188         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24189         txdata_constr.datalen = txdata->arr_len;
24190         if (txdata_constr.datalen > 0)
24191                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24192         else
24193                 txdata_constr.data = NULL;
24194         uint32_t* txdata_vals = txdata->elems;
24195         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24196                 uint32_t txdata_conv_28 = txdata_vals[c];
24197                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24198                 CHECK_ACCESS(txdata_conv_28_ptr);
24199                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24200                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24201                 txdata_constr.data[c] = txdata_conv_28_conv;
24202         }
24203         FREE(txdata);
24204         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24205         CHECK_ACCESS(broadcaster_ptr);
24206         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24207         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24208                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24209                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24210         }
24211         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24212         CHECK_ACCESS(fee_estimator_ptr);
24213         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24214         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24216                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24217         }
24218         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24219         CHECK_ACCESS(logger_ptr);
24220         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24221         if (logger_conv.free == LDKLogger_JCalls_free) {
24222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24223                 LDKLogger_JCalls_cloned(&logger_conv);
24224         }
24225         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);
24226         uint32_tArray ret_arr = NULL;
24227         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24228         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24229         for (size_t n = 0; n < ret_var.datalen; n++) {
24230                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24231                 *ret_conv_39_conv = ret_var.data[n];
24232                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24233         }
24234         
24235         FREE(ret_var.data);
24236         return ret_arr;
24237 }
24238
24239 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) {
24240         LDKChannelMonitor this_arg_conv;
24241         this_arg_conv.inner = (void*)(this_arg & (~1));
24242         this_arg_conv.is_owned = false;
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24244         unsigned char txid_arr[32];
24245         CHECK(txid->arr_len == 32);
24246         memcpy(txid_arr, txid->elems, 32); FREE(txid);
24247         unsigned char (*txid_ref)[32] = &txid_arr;
24248         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24249         CHECK_ACCESS(broadcaster_ptr);
24250         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24251         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24252                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24253                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24254         }
24255         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24256         CHECK_ACCESS(fee_estimator_ptr);
24257         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24258         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24260                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24261         }
24262         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24263         CHECK_ACCESS(logger_ptr);
24264         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24265         if (logger_conv.free == LDKLogger_JCalls_free) {
24266                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24267                 LDKLogger_JCalls_cloned(&logger_conv);
24268         }
24269         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
24270 }
24271
24272 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) {
24273         LDKChannelMonitor this_arg_conv;
24274         this_arg_conv.inner = (void*)(this_arg & (~1));
24275         this_arg_conv.is_owned = false;
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24277         unsigned char header_arr[80];
24278         CHECK(header->arr_len == 80);
24279         memcpy(header_arr, header->elems, 80); FREE(header);
24280         unsigned char (*header_ref)[80] = &header_arr;
24281         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24282         CHECK_ACCESS(broadcaster_ptr);
24283         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24284         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24286                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24287         }
24288         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24289         CHECK_ACCESS(fee_estimator_ptr);
24290         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24291         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24293                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24294         }
24295         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24296         CHECK_ACCESS(logger_ptr);
24297         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24298         if (logger_conv.free == LDKLogger_JCalls_free) {
24299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24300                 LDKLogger_JCalls_cloned(&logger_conv);
24301         }
24302         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24303         uint32_tArray ret_arr = NULL;
24304         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24305         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24306         for (size_t n = 0; n < ret_var.datalen; n++) {
24307                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24308                 *ret_conv_39_conv = ret_var.data[n];
24309                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24310         }
24311         
24312         FREE(ret_var.data);
24313         return ret_arr;
24314 }
24315
24316 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
24317         LDKChannelMonitor this_arg_conv;
24318         this_arg_conv.inner = (void*)(this_arg & (~1));
24319         this_arg_conv.is_owned = false;
24320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24321         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
24322         ptrArray ret_arr = NULL;
24323         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24324         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
24325         for (size_t m = 0; m < ret_var.datalen; m++) {
24326                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
24327                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
24328                 ret_arr_ptr[m] = ret_conv_12_arr;
24329         }
24330         
24331         FREE(ret_var.data);
24332         return ret_arr;
24333 }
24334
24335 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
24336         LDKChannelMonitor this_arg_conv;
24337         this_arg_conv.inner = (void*)(this_arg & (~1));
24338         this_arg_conv.is_owned = false;
24339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24340         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
24341         uint32_t ret_ref = 0;
24342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24345         ret_ref = (uintptr_t)ret_var.inner;
24346         if (ret_var.is_owned) {
24347                 ret_ref |= 1;
24348         }
24349         return ret_ref;
24350 }
24351
24352 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
24353         LDKChannelMonitor this_arg_conv;
24354         this_arg_conv.inner = (void*)(this_arg & (~1));
24355         this_arg_conv.is_owned = false;
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24357         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
24358         uint32_tArray ret_arr = NULL;
24359         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24360         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
24361         for (size_t j = 0; j < ret_var.datalen; j++) {
24362                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24363                 *ret_conv_9_copy = ret_var.data[j];
24364                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
24365                 ret_arr_ptr[j] = ret_conv_9_ref;
24366         }
24367         
24368         FREE(ret_var.data);
24369         return ret_arr;
24370 }
24371
24372 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
24373         LDKu8slice ser_ref;
24374         ser_ref.datalen = ser->arr_len;
24375         ser_ref.data = ser->elems;
24376         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24377         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24378         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
24379         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
24380         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
24381         FREE(ser);
24382         return (uint32_t)ret_conv;
24383 }
24384
24385 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
24386         LDKOutPoint this_obj_conv;
24387         this_obj_conv.inner = (void*)(this_obj & (~1));
24388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24390         OutPoint_free(this_obj_conv);
24391 }
24392
24393 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
24394         LDKOutPoint this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24398         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24399         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
24400         return ret_arr;
24401 }
24402
24403 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
24404         LDKOutPoint this_ptr_conv;
24405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24406         this_ptr_conv.is_owned = false;
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24408         LDKThirtyTwoBytes val_ref;
24409         CHECK(val->arr_len == 32);
24410         memcpy(val_ref.data, val->elems, 32); FREE(val);
24411         OutPoint_set_txid(&this_ptr_conv, val_ref);
24412 }
24413
24414 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
24415         LDKOutPoint this_ptr_conv;
24416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24417         this_ptr_conv.is_owned = false;
24418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24419         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
24420         return ret_conv;
24421 }
24422
24423 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
24424         LDKOutPoint this_ptr_conv;
24425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24426         this_ptr_conv.is_owned = false;
24427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24428         OutPoint_set_index(&this_ptr_conv, val);
24429 }
24430
24431 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
24432         LDKThirtyTwoBytes txid_arg_ref;
24433         CHECK(txid_arg->arr_len == 32);
24434         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
24435         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
24436         uint32_t ret_ref = 0;
24437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24440         ret_ref = (uintptr_t)ret_var.inner;
24441         if (ret_var.is_owned) {
24442                 ret_ref |= 1;
24443         }
24444         return ret_ref;
24445 }
24446
24447 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
24448         LDKOutPoint ret_var = OutPoint_clone(arg);
24449 uint32_t ret_ref = 0;
24450 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24451 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24452 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24453 ret_ref = (uintptr_t)ret_var.inner;
24454 if (ret_var.is_owned) {
24455         ret_ref |= 1;
24456 }
24457         return ret_ref;
24458 }
24459 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
24460         LDKOutPoint arg_conv;
24461         arg_conv.inner = (void*)(arg & (~1));
24462         arg_conv.is_owned = false;
24463         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24464         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
24465         return ret_conv;
24466 }
24467
24468 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
24469         LDKOutPoint orig_conv;
24470         orig_conv.inner = (void*)(orig & (~1));
24471         orig_conv.is_owned = false;
24472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24473         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
24474         uint32_t ret_ref = 0;
24475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24478         ret_ref = (uintptr_t)ret_var.inner;
24479         if (ret_var.is_owned) {
24480                 ret_ref |= 1;
24481         }
24482         return ret_ref;
24483 }
24484
24485 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
24486         LDKOutPoint a_conv;
24487         a_conv.inner = (void*)(a & (~1));
24488         a_conv.is_owned = false;
24489         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24490         LDKOutPoint b_conv;
24491         b_conv.inner = (void*)(b & (~1));
24492         b_conv.is_owned = false;
24493         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24494         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
24495         return ret_conv;
24496 }
24497
24498 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
24499         LDKOutPoint o_conv;
24500         o_conv.inner = (void*)(o & (~1));
24501         o_conv.is_owned = false;
24502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24503         int64_t ret_conv = OutPoint_hash(&o_conv);
24504         return ret_conv;
24505 }
24506
24507 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
24508         LDKOutPoint this_arg_conv;
24509         this_arg_conv.inner = (void*)(this_arg & (~1));
24510         this_arg_conv.is_owned = false;
24511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24512         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24513         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
24514         return ret_arr;
24515 }
24516
24517 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
24518         LDKOutPoint obj_conv;
24519         obj_conv.inner = (void*)(obj & (~1));
24520         obj_conv.is_owned = false;
24521         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24522         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
24523         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24524         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24525         CVec_u8Z_free(ret_var);
24526         return ret_arr;
24527 }
24528
24529 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
24530         LDKu8slice ser_ref;
24531         ser_ref.datalen = ser->arr_len;
24532         ser_ref.data = ser->elems;
24533         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
24534         *ret_conv = OutPoint_read(ser_ref);
24535         FREE(ser);
24536         return (uint32_t)ret_conv;
24537 }
24538
24539 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
24540         LDKDelayedPaymentOutputDescriptor this_obj_conv;
24541         this_obj_conv.inner = (void*)(this_obj & (~1));
24542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24544         DelayedPaymentOutputDescriptor_free(this_obj_conv);
24545 }
24546
24547 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24548         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24550         this_ptr_conv.is_owned = false;
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24552         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24553         uint32_t ret_ref = 0;
24554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24557         ret_ref = (uintptr_t)ret_var.inner;
24558         if (ret_var.is_owned) {
24559                 ret_ref |= 1;
24560         }
24561         return ret_ref;
24562 }
24563
24564 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24565         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24567         this_ptr_conv.is_owned = false;
24568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24569         LDKOutPoint val_conv;
24570         val_conv.inner = (void*)(val & (~1));
24571         val_conv.is_owned = (val & 1) || (val == 0);
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24573         val_conv = OutPoint_clone(&val_conv);
24574         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24575 }
24576
24577 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
24578         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24580         this_ptr_conv.is_owned = false;
24581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24582         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24583         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24584         return ret_arr;
24585 }
24586
24587 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24588         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24590         this_ptr_conv.is_owned = false;
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24592         LDKPublicKey val_ref;
24593         CHECK(val->arr_len == 33);
24594         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24595         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
24596 }
24597
24598 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
24599         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24603         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
24604         return ret_conv;
24605 }
24606
24607 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
24608         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24610         this_ptr_conv.is_owned = false;
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24612         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
24613 }
24614
24615 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24616         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24618         this_ptr_conv.is_owned = false;
24619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24620         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24621         CHECK_ACCESS(val_ptr);
24622         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24623         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24624         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24625 }
24626
24627 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
24628         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24630         this_ptr_conv.is_owned = false;
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24632         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24633         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24634         return ret_arr;
24635 }
24636
24637 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
24638         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24640         this_ptr_conv.is_owned = false;
24641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24642         LDKPublicKey val_ref;
24643         CHECK(val->arr_len == 33);
24644         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24645         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24646 }
24647
24648 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24649         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24651         this_ptr_conv.is_owned = false;
24652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24653         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24654         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24655         return ret_arr;
24656 }
24657
24658 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24659         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24661         this_ptr_conv.is_owned = false;
24662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24663         LDKThirtyTwoBytes val_ref;
24664         CHECK(val->arr_len == 32);
24665         memcpy(val_ref.data, val->elems, 32); FREE(val);
24666         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24667 }
24668
24669 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24670         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24672         this_ptr_conv.is_owned = false;
24673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24674         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24675         return ret_conv;
24676 }
24677
24678 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24679         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24681         this_ptr_conv.is_owned = false;
24682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24683         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24684 }
24685
24686 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) {
24687         LDKOutPoint outpoint_arg_conv;
24688         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24689         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24690         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24691         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24692         LDKPublicKey per_commitment_point_arg_ref;
24693         CHECK(per_commitment_point_arg->arr_len == 33);
24694         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24695         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24696         CHECK_ACCESS(output_arg_ptr);
24697         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24698         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24699         LDKPublicKey revocation_pubkey_arg_ref;
24700         CHECK(revocation_pubkey_arg->arr_len == 33);
24701         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24702         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24703         CHECK(channel_keys_id_arg->arr_len == 32);
24704         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24705         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);
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 DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24718         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_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_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24730         LDKDelayedPaymentOutputDescriptor 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_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24735         return ret_conv;
24736 }
24737
24738 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
24739         LDKDelayedPaymentOutputDescriptor 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         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_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 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
24756         LDKDelayedPaymentOutputDescriptor obj_conv;
24757         obj_conv.inner = (void*)(obj & (~1));
24758         obj_conv.is_owned = false;
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24760         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24763         CVec_u8Z_free(ret_var);
24764         return ret_arr;
24765 }
24766
24767 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24768         LDKu8slice ser_ref;
24769         ser_ref.datalen = ser->arr_len;
24770         ser_ref.data = ser->elems;
24771         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24772         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24773         FREE(ser);
24774         return (uint32_t)ret_conv;
24775 }
24776
24777 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
24778         LDKStaticPaymentOutputDescriptor this_obj_conv;
24779         this_obj_conv.inner = (void*)(this_obj & (~1));
24780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24782         StaticPaymentOutputDescriptor_free(this_obj_conv);
24783 }
24784
24785 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24786         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24788         this_ptr_conv.is_owned = false;
24789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24790         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24791         uint32_t ret_ref = 0;
24792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24795         ret_ref = (uintptr_t)ret_var.inner;
24796         if (ret_var.is_owned) {
24797                 ret_ref |= 1;
24798         }
24799         return ret_ref;
24800 }
24801
24802 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24803         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24805         this_ptr_conv.is_owned = false;
24806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24807         LDKOutPoint val_conv;
24808         val_conv.inner = (void*)(val & (~1));
24809         val_conv.is_owned = (val & 1) || (val == 0);
24810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24811         val_conv = OutPoint_clone(&val_conv);
24812         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24813 }
24814
24815 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24816         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24818         this_ptr_conv.is_owned = false;
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24820         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24821         CHECK_ACCESS(val_ptr);
24822         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24823         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24824         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24825 }
24826
24827 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24828         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24830         this_ptr_conv.is_owned = false;
24831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24832         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24833         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24834         return ret_arr;
24835 }
24836
24837 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24838         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24840         this_ptr_conv.is_owned = false;
24841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24842         LDKThirtyTwoBytes val_ref;
24843         CHECK(val->arr_len == 32);
24844         memcpy(val_ref.data, val->elems, 32); FREE(val);
24845         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24846 }
24847
24848 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24849         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24851         this_ptr_conv.is_owned = false;
24852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24853         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24854         return ret_conv;
24855 }
24856
24857 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24858         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24860         this_ptr_conv.is_owned = false;
24861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24862         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24863 }
24864
24865 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) {
24866         LDKOutPoint outpoint_arg_conv;
24867         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24868         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24870         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24871         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24872         CHECK_ACCESS(output_arg_ptr);
24873         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24874         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24875         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24876         CHECK(channel_keys_id_arg->arr_len == 32);
24877         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24878         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24879         uint32_t ret_ref = 0;
24880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24883         ret_ref = (uintptr_t)ret_var.inner;
24884         if (ret_var.is_owned) {
24885                 ret_ref |= 1;
24886         }
24887         return ret_ref;
24888 }
24889
24890 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24891         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24892 uint32_t ret_ref = 0;
24893 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24894 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24895 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24896 ret_ref = (uintptr_t)ret_var.inner;
24897 if (ret_var.is_owned) {
24898         ret_ref |= 1;
24899 }
24900         return ret_ref;
24901 }
24902 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24903         LDKStaticPaymentOutputDescriptor arg_conv;
24904         arg_conv.inner = (void*)(arg & (~1));
24905         arg_conv.is_owned = false;
24906         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24907         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24908         return ret_conv;
24909 }
24910
24911 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
24912         LDKStaticPaymentOutputDescriptor orig_conv;
24913         orig_conv.inner = (void*)(orig & (~1));
24914         orig_conv.is_owned = false;
24915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24916         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24917         uint32_t ret_ref = 0;
24918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24921         ret_ref = (uintptr_t)ret_var.inner;
24922         if (ret_var.is_owned) {
24923                 ret_ref |= 1;
24924         }
24925         return ret_ref;
24926 }
24927
24928 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
24929         LDKStaticPaymentOutputDescriptor obj_conv;
24930         obj_conv.inner = (void*)(obj & (~1));
24931         obj_conv.is_owned = false;
24932         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24933         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24934         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24935         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24936         CVec_u8Z_free(ret_var);
24937         return ret_arr;
24938 }
24939
24940 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24941         LDKu8slice ser_ref;
24942         ser_ref.datalen = ser->arr_len;
24943         ser_ref.data = ser->elems;
24944         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24945         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24946         FREE(ser);
24947         return (uint32_t)ret_conv;
24948 }
24949
24950 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
24951         if ((this_ptr & 1) != 0) return;
24952         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24953         CHECK_ACCESS(this_ptr_ptr);
24954         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24955         FREE((void*)this_ptr);
24956         SpendableOutputDescriptor_free(this_ptr_conv);
24957 }
24958
24959 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
24960         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24961         *ret_copy = SpendableOutputDescriptor_clone(arg);
24962 uint32_t ret_ref = (uintptr_t)ret_copy;
24963         return ret_ref;
24964 }
24965 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
24966         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
24967         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
24968         return ret_conv;
24969 }
24970
24971 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
24972         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24973         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24974         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24975         uint32_t ret_ref = (uintptr_t)ret_copy;
24976         return ret_ref;
24977 }
24978
24979 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
24980         LDKOutPoint outpoint_conv;
24981         outpoint_conv.inner = (void*)(outpoint & (~1));
24982         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
24983         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
24984         outpoint_conv = OutPoint_clone(&outpoint_conv);
24985         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
24986         CHECK_ACCESS(output_ptr);
24987         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
24988         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
24989         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24990         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
24991         uint32_t ret_ref = (uintptr_t)ret_copy;
24992         return ret_ref;
24993 }
24994
24995 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
24996         LDKDelayedPaymentOutputDescriptor a_conv;
24997         a_conv.inner = (void*)(a & (~1));
24998         a_conv.is_owned = (a & 1) || (a == 0);
24999         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25000         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
25001         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25002         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
25003         uint32_t ret_ref = (uintptr_t)ret_copy;
25004         return ret_ref;
25005 }
25006
25007 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
25008         LDKStaticPaymentOutputDescriptor a_conv;
25009         a_conv.inner = (void*)(a & (~1));
25010         a_conv.is_owned = (a & 1) || (a == 0);
25011         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25012         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
25013         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25014         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
25015         uint32_t ret_ref = (uintptr_t)ret_copy;
25016         return ret_ref;
25017 }
25018
25019 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
25020         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
25021         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
25022         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25023         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25024         CVec_u8Z_free(ret_var);
25025         return ret_arr;
25026 }
25027
25028 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
25029         LDKu8slice ser_ref;
25030         ser_ref.datalen = ser->arr_len;
25031         ser_ref.data = ser->elems;
25032         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
25033         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
25034         FREE(ser);
25035         return (uint32_t)ret_conv;
25036 }
25037
25038 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
25039         if ((this_ptr & 1) != 0) return;
25040         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25041         CHECK_ACCESS(this_ptr_ptr);
25042         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
25043         FREE((void*)this_ptr);
25044         BaseSign_free(this_ptr_conv);
25045 }
25046
25047 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
25048         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25049         *ret_ret = Sign_clone(arg);
25050         return (uint32_t)ret_ret;
25051 }
25052 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
25053         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
25054         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
25055         LDKSign* arg_conv = (LDKSign*)arg_ptr;
25056         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
25057         return ret_conv;
25058 }
25059
25060 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
25061         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
25062         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25063         LDKSign* orig_conv = (LDKSign*)orig_ptr;
25064         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25065         *ret_ret = Sign_clone(orig_conv);
25066         return (uint32_t)ret_ret;
25067 }
25068
25069 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
25070         if ((this_ptr & 1) != 0) return;
25071         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25072         CHECK_ACCESS(this_ptr_ptr);
25073         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
25074         FREE((void*)this_ptr);
25075         Sign_free(this_ptr_conv);
25076 }
25077
25078 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
25079         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
25080         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
25081         return ret_conv;
25082 }
25083
25084 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
25085         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
25086         return ret_conv;
25087 }
25088
25089 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
25090         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
25091         return ret_conv;
25092 }
25093
25094 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
25095         if ((this_ptr & 1) != 0) return;
25096         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25097         CHECK_ACCESS(this_ptr_ptr);
25098         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
25099         FREE((void*)this_ptr);
25100         KeysInterface_free(this_ptr_conv);
25101 }
25102
25103 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
25104         LDKInMemorySigner this_obj_conv;
25105         this_obj_conv.inner = (void*)(this_obj & (~1));
25106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25108         InMemorySigner_free(this_obj_conv);
25109 }
25110
25111 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
25112         LDKInMemorySigner this_ptr_conv;
25113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25114         this_ptr_conv.is_owned = false;
25115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25116         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25117         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
25118         return ret_arr;
25119 }
25120
25121 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
25122         LDKInMemorySigner this_ptr_conv;
25123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25124         this_ptr_conv.is_owned = false;
25125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25126         LDKSecretKey val_ref;
25127         CHECK(val->arr_len == 32);
25128         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25129         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
25130 }
25131
25132 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
25133         LDKInMemorySigner this_ptr_conv;
25134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25135         this_ptr_conv.is_owned = false;
25136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25137         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25138         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
25139         return ret_arr;
25140 }
25141
25142 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
25143         LDKInMemorySigner this_ptr_conv;
25144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25145         this_ptr_conv.is_owned = false;
25146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25147         LDKSecretKey val_ref;
25148         CHECK(val->arr_len == 32);
25149         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25150         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
25151 }
25152
25153 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
25154         LDKInMemorySigner this_ptr_conv;
25155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25156         this_ptr_conv.is_owned = false;
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25158         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25159         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
25160         return ret_arr;
25161 }
25162
25163 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
25164         LDKInMemorySigner this_ptr_conv;
25165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25166         this_ptr_conv.is_owned = false;
25167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25168         LDKSecretKey val_ref;
25169         CHECK(val->arr_len == 32);
25170         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25171         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
25172 }
25173
25174 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
25175         LDKInMemorySigner this_ptr_conv;
25176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25177         this_ptr_conv.is_owned = false;
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25179         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25180         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
25181         return ret_arr;
25182 }
25183
25184 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) {
25185         LDKInMemorySigner this_ptr_conv;
25186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25187         this_ptr_conv.is_owned = false;
25188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25189         LDKSecretKey val_ref;
25190         CHECK(val->arr_len == 32);
25191         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25192         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
25193 }
25194
25195 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
25196         LDKInMemorySigner this_ptr_conv;
25197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25198         this_ptr_conv.is_owned = false;
25199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25200         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25201         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
25202         return ret_arr;
25203 }
25204
25205 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
25206         LDKInMemorySigner this_ptr_conv;
25207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25208         this_ptr_conv.is_owned = false;
25209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25210         LDKSecretKey val_ref;
25211         CHECK(val->arr_len == 32);
25212         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25213         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
25214 }
25215
25216 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
25217         LDKInMemorySigner this_ptr_conv;
25218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25219         this_ptr_conv.is_owned = false;
25220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25221         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25222         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
25223         return ret_arr;
25224 }
25225
25226 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
25227         LDKInMemorySigner this_ptr_conv;
25228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25229         this_ptr_conv.is_owned = false;
25230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25231         LDKThirtyTwoBytes val_ref;
25232         CHECK(val->arr_len == 32);
25233         memcpy(val_ref.data, val->elems, 32); FREE(val);
25234         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
25235 }
25236
25237 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
25238         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
25239 uint32_t ret_ref = 0;
25240 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25241 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25242 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25243 ret_ref = (uintptr_t)ret_var.inner;
25244 if (ret_var.is_owned) {
25245         ret_ref |= 1;
25246 }
25247         return ret_ref;
25248 }
25249 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
25250         LDKInMemorySigner arg_conv;
25251         arg_conv.inner = (void*)(arg & (~1));
25252         arg_conv.is_owned = false;
25253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25254         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
25255         return ret_conv;
25256 }
25257
25258 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
25259         LDKInMemorySigner orig_conv;
25260         orig_conv.inner = (void*)(orig & (~1));
25261         orig_conv.is_owned = false;
25262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25263         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
25264         uint32_t ret_ref = 0;
25265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25268         ret_ref = (uintptr_t)ret_var.inner;
25269         if (ret_var.is_owned) {
25270                 ret_ref |= 1;
25271         }
25272         return ret_ref;
25273 }
25274
25275 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) {
25276         LDKSecretKey node_secret_ref;
25277         CHECK(node_secret->arr_len == 32);
25278         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
25279         LDKSecretKey funding_key_ref;
25280         CHECK(funding_key->arr_len == 32);
25281         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
25282         LDKSecretKey revocation_base_key_ref;
25283         CHECK(revocation_base_key->arr_len == 32);
25284         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
25285         LDKSecretKey payment_key_ref;
25286         CHECK(payment_key->arr_len == 32);
25287         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
25288         LDKSecretKey delayed_payment_base_key_ref;
25289         CHECK(delayed_payment_base_key->arr_len == 32);
25290         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
25291         LDKSecretKey htlc_base_key_ref;
25292         CHECK(htlc_base_key->arr_len == 32);
25293         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
25294         LDKThirtyTwoBytes commitment_seed_ref;
25295         CHECK(commitment_seed->arr_len == 32);
25296         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
25297         LDKThirtyTwoBytes channel_keys_id_ref;
25298         CHECK(channel_keys_id->arr_len == 32);
25299         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
25300         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);
25301         uint32_t ret_ref = 0;
25302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25305         ret_ref = (uintptr_t)ret_var.inner;
25306         if (ret_var.is_owned) {
25307                 ret_ref |= 1;
25308         }
25309         return ret_ref;
25310 }
25311
25312 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
25313         LDKInMemorySigner this_arg_conv;
25314         this_arg_conv.inner = (void*)(this_arg & (~1));
25315         this_arg_conv.is_owned = false;
25316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25317         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
25318         uint32_t ret_ref = 0;
25319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25322         ret_ref = (uintptr_t)ret_var.inner;
25323         if (ret_var.is_owned) {
25324                 ret_ref |= 1;
25325         }
25326         return ret_ref;
25327 }
25328
25329 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
25330         LDKInMemorySigner this_arg_conv;
25331         this_arg_conv.inner = (void*)(this_arg & (~1));
25332         this_arg_conv.is_owned = false;
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25334         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
25335         return ret_conv;
25336 }
25337
25338 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
25339         LDKInMemorySigner this_arg_conv;
25340         this_arg_conv.inner = (void*)(this_arg & (~1));
25341         this_arg_conv.is_owned = false;
25342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25343         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
25344         return ret_conv;
25345 }
25346
25347 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
25348         LDKInMemorySigner this_arg_conv;
25349         this_arg_conv.inner = (void*)(this_arg & (~1));
25350         this_arg_conv.is_owned = false;
25351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25352         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
25353         return ret_conv;
25354 }
25355
25356 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
25357         LDKInMemorySigner this_arg_conv;
25358         this_arg_conv.inner = (void*)(this_arg & (~1));
25359         this_arg_conv.is_owned = false;
25360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25361         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
25362         uint32_t ret_ref = 0;
25363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25366         ret_ref = (uintptr_t)ret_var.inner;
25367         if (ret_var.is_owned) {
25368                 ret_ref |= 1;
25369         }
25370         return ret_ref;
25371 }
25372
25373 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
25374         LDKInMemorySigner this_arg_conv;
25375         this_arg_conv.inner = (void*)(this_arg & (~1));
25376         this_arg_conv.is_owned = false;
25377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25378         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
25379         uint32_t ret_ref = 0;
25380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25383         ret_ref = (uintptr_t)ret_var.inner;
25384         if (ret_var.is_owned) {
25385                 ret_ref |= 1;
25386         }
25387         return ret_ref;
25388 }
25389
25390 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
25391         LDKInMemorySigner this_arg_conv;
25392         this_arg_conv.inner = (void*)(this_arg & (~1));
25393         this_arg_conv.is_owned = false;
25394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25395         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
25396         return ret_conv;
25397 }
25398
25399 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) {
25400         LDKInMemorySigner this_arg_conv;
25401         this_arg_conv.inner = (void*)(this_arg & (~1));
25402         this_arg_conv.is_owned = false;
25403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25404         LDKTransaction spend_tx_ref;
25405         spend_tx_ref.datalen = spend_tx->arr_len;
25406         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25407         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25408         spend_tx_ref.data_is_owned = true;
25409         LDKStaticPaymentOutputDescriptor descriptor_conv;
25410         descriptor_conv.inner = (void*)(descriptor & (~1));
25411         descriptor_conv.is_owned = false;
25412         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25413         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25414         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25415         return (uint32_t)ret_conv;
25416 }
25417
25418 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) {
25419         LDKInMemorySigner this_arg_conv;
25420         this_arg_conv.inner = (void*)(this_arg & (~1));
25421         this_arg_conv.is_owned = false;
25422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25423         LDKTransaction spend_tx_ref;
25424         spend_tx_ref.datalen = spend_tx->arr_len;
25425         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25426         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25427         spend_tx_ref.data_is_owned = true;
25428         LDKDelayedPaymentOutputDescriptor descriptor_conv;
25429         descriptor_conv.inner = (void*)(descriptor & (~1));
25430         descriptor_conv.is_owned = false;
25431         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25432         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25433         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25434         return (uint32_t)ret_conv;
25435 }
25436
25437 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
25438         LDKInMemorySigner this_arg_conv;
25439         this_arg_conv.inner = (void*)(this_arg & (~1));
25440         this_arg_conv.is_owned = false;
25441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25442         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
25443         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
25444         return (uint32_t)ret_ret;
25445 }
25446
25447 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
25448         LDKInMemorySigner this_arg_conv;
25449         this_arg_conv.inner = (void*)(this_arg & (~1));
25450         this_arg_conv.is_owned = false;
25451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25452         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25453         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
25454         return (uint32_t)ret_ret;
25455 }
25456
25457 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
25458         LDKInMemorySigner obj_conv;
25459         obj_conv.inner = (void*)(obj & (~1));
25460         obj_conv.is_owned = false;
25461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25462         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
25463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25465         CVec_u8Z_free(ret_var);
25466         return ret_arr;
25467 }
25468
25469 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
25470         LDKu8slice ser_ref;
25471         ser_ref.datalen = ser->arr_len;
25472         ser_ref.data = ser->elems;
25473         LDKSecretKey arg_ref;
25474         CHECK(arg->arr_len == 32);
25475         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
25476         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
25477         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
25478         FREE(ser);
25479         return (uint32_t)ret_conv;
25480 }
25481
25482 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
25483         LDKKeysManager this_obj_conv;
25484         this_obj_conv.inner = (void*)(this_obj & (~1));
25485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25487         KeysManager_free(this_obj_conv);
25488 }
25489
25490 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
25491         unsigned char seed_arr[32];
25492         CHECK(seed->arr_len == 32);
25493         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25494         unsigned char (*seed_ref)[32] = &seed_arr;
25495         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
25496         uint32_t ret_ref = 0;
25497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25500         ret_ref = (uintptr_t)ret_var.inner;
25501         if (ret_var.is_owned) {
25502                 ret_ref |= 1;
25503         }
25504         return ret_ref;
25505 }
25506
25507 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) {
25508         LDKKeysManager this_arg_conv;
25509         this_arg_conv.inner = (void*)(this_arg & (~1));
25510         this_arg_conv.is_owned = false;
25511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25512         unsigned char params_arr[32];
25513         CHECK(params->arr_len == 32);
25514         memcpy(params_arr, params->elems, 32); FREE(params);
25515         unsigned char (*params_ref)[32] = &params_arr;
25516         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25517         uint32_t ret_ref = 0;
25518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25521         ret_ref = (uintptr_t)ret_var.inner;
25522         if (ret_var.is_owned) {
25523                 ret_ref |= 1;
25524         }
25525         return ret_ref;
25526 }
25527
25528 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) {
25529         LDKKeysManager this_arg_conv;
25530         this_arg_conv.inner = (void*)(this_arg & (~1));
25531         this_arg_conv.is_owned = false;
25532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25533         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25534         descriptors_constr.datalen = descriptors->arr_len;
25535         if (descriptors_constr.datalen > 0)
25536                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25537         else
25538                 descriptors_constr.data = NULL;
25539         uint32_t* descriptors_vals = descriptors->elems;
25540         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25541                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25542                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25543                 CHECK_ACCESS(descriptors_conv_27_ptr);
25544                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25545                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25546                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25547         }
25548         FREE(descriptors);
25549         LDKCVec_TxOutZ outputs_constr;
25550         outputs_constr.datalen = outputs->arr_len;
25551         if (outputs_constr.datalen > 0)
25552                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25553         else
25554                 outputs_constr.data = NULL;
25555         uint32_t* outputs_vals = outputs->elems;
25556         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25557                 uint32_t outputs_conv_7 = outputs_vals[h];
25558                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25559                 CHECK_ACCESS(outputs_conv_7_ptr);
25560                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25561                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25562                 outputs_constr.data[h] = outputs_conv_7_conv;
25563         }
25564         FREE(outputs);
25565         LDKCVec_u8Z change_destination_script_ref;
25566         change_destination_script_ref.datalen = change_destination_script->arr_len;
25567         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25568         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25569         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25570         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25571         return (uint32_t)ret_conv;
25572 }
25573
25574 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
25575         LDKKeysManager this_arg_conv;
25576         this_arg_conv.inner = (void*)(this_arg & (~1));
25577         this_arg_conv.is_owned = false;
25578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25579         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25580         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
25581         return (uint32_t)ret_ret;
25582 }
25583
25584 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
25585         LDKPhantomKeysManager this_obj_conv;
25586         this_obj_conv.inner = (void*)(this_obj & (~1));
25587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25589         PhantomKeysManager_free(this_obj_conv);
25590 }
25591
25592 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
25593         LDKPhantomKeysManager this_arg_conv;
25594         this_arg_conv.inner = (void*)(this_arg & (~1));
25595         this_arg_conv.is_owned = false;
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25597         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25598         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
25599         return (uint32_t)ret_ret;
25600 }
25601
25602 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) {
25603         unsigned char seed_arr[32];
25604         CHECK(seed->arr_len == 32);
25605         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25606         unsigned char (*seed_ref)[32] = &seed_arr;
25607         unsigned char cross_node_seed_arr[32];
25608         CHECK(cross_node_seed->arr_len == 32);
25609         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
25610         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
25611         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
25612         uint32_t ret_ref = 0;
25613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25616         ret_ref = (uintptr_t)ret_var.inner;
25617         if (ret_var.is_owned) {
25618                 ret_ref |= 1;
25619         }
25620         return ret_ref;
25621 }
25622
25623 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) {
25624         LDKPhantomKeysManager this_arg_conv;
25625         this_arg_conv.inner = (void*)(this_arg & (~1));
25626         this_arg_conv.is_owned = false;
25627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25628         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25629         descriptors_constr.datalen = descriptors->arr_len;
25630         if (descriptors_constr.datalen > 0)
25631                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25632         else
25633                 descriptors_constr.data = NULL;
25634         uint32_t* descriptors_vals = descriptors->elems;
25635         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25636                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25637                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25638                 CHECK_ACCESS(descriptors_conv_27_ptr);
25639                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25640                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25641                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25642         }
25643         FREE(descriptors);
25644         LDKCVec_TxOutZ outputs_constr;
25645         outputs_constr.datalen = outputs->arr_len;
25646         if (outputs_constr.datalen > 0)
25647                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25648         else
25649                 outputs_constr.data = NULL;
25650         uint32_t* outputs_vals = outputs->elems;
25651         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25652                 uint32_t outputs_conv_7 = outputs_vals[h];
25653                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25654                 CHECK_ACCESS(outputs_conv_7_ptr);
25655                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25656                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25657                 outputs_constr.data[h] = outputs_conv_7_conv;
25658         }
25659         FREE(outputs);
25660         LDKCVec_u8Z change_destination_script_ref;
25661         change_destination_script_ref.datalen = change_destination_script->arr_len;
25662         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25663         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25664         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25665         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25666         return (uint32_t)ret_conv;
25667 }
25668
25669 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) {
25670         LDKPhantomKeysManager this_arg_conv;
25671         this_arg_conv.inner = (void*)(this_arg & (~1));
25672         this_arg_conv.is_owned = false;
25673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25674         unsigned char params_arr[32];
25675         CHECK(params->arr_len == 32);
25676         memcpy(params_arr, params->elems, 32); FREE(params);
25677         unsigned char (*params_ref)[32] = &params_arr;
25678         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25679         uint32_t ret_ref = 0;
25680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25683         ret_ref = (uintptr_t)ret_var.inner;
25684         if (ret_var.is_owned) {
25685                 ret_ref |= 1;
25686         }
25687         return ret_ref;
25688 }
25689
25690 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
25691         LDKChannelManager this_obj_conv;
25692         this_obj_conv.inner = (void*)(this_obj & (~1));
25693         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25695         ChannelManager_free(this_obj_conv);
25696 }
25697
25698 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
25699         LDKChainParameters this_obj_conv;
25700         this_obj_conv.inner = (void*)(this_obj & (~1));
25701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25703         ChainParameters_free(this_obj_conv);
25704 }
25705
25706 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
25707         LDKChainParameters this_ptr_conv;
25708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25709         this_ptr_conv.is_owned = false;
25710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25711         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25712         return ret_conv;
25713 }
25714
25715 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
25716         LDKChainParameters this_ptr_conv;
25717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25718         this_ptr_conv.is_owned = false;
25719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25720         LDKNetwork val_conv = LDKNetwork_from_js(val);
25721         ChainParameters_set_network(&this_ptr_conv, val_conv);
25722 }
25723
25724 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
25725         LDKChainParameters this_ptr_conv;
25726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25727         this_ptr_conv.is_owned = false;
25728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25729         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25730         uint32_t ret_ref = 0;
25731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25734         ret_ref = (uintptr_t)ret_var.inner;
25735         if (ret_var.is_owned) {
25736                 ret_ref |= 1;
25737         }
25738         return ret_ref;
25739 }
25740
25741 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
25742         LDKChainParameters this_ptr_conv;
25743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25744         this_ptr_conv.is_owned = false;
25745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25746         LDKBestBlock val_conv;
25747         val_conv.inner = (void*)(val & (~1));
25748         val_conv.is_owned = (val & 1) || (val == 0);
25749         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25750         val_conv = BestBlock_clone(&val_conv);
25751         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25752 }
25753
25754 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
25755         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25756         LDKBestBlock best_block_arg_conv;
25757         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25758         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25759         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25760         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25761         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25762         uint32_t ret_ref = 0;
25763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25766         ret_ref = (uintptr_t)ret_var.inner;
25767         if (ret_var.is_owned) {
25768                 ret_ref |= 1;
25769         }
25770         return ret_ref;
25771 }
25772
25773 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25774         LDKChainParameters ret_var = ChainParameters_clone(arg);
25775 uint32_t ret_ref = 0;
25776 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25777 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25778 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25779 ret_ref = (uintptr_t)ret_var.inner;
25780 if (ret_var.is_owned) {
25781         ret_ref |= 1;
25782 }
25783         return ret_ref;
25784 }
25785 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
25786         LDKChainParameters arg_conv;
25787         arg_conv.inner = (void*)(arg & (~1));
25788         arg_conv.is_owned = false;
25789         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25790         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25791         return ret_conv;
25792 }
25793
25794 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
25795         LDKChainParameters orig_conv;
25796         orig_conv.inner = (void*)(orig & (~1));
25797         orig_conv.is_owned = false;
25798         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25799         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25800         uint32_t ret_ref = 0;
25801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25804         ret_ref = (uintptr_t)ret_var.inner;
25805         if (ret_var.is_owned) {
25806                 ret_ref |= 1;
25807         }
25808         return ret_ref;
25809 }
25810
25811 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
25812         LDKCounterpartyForwardingInfo this_obj_conv;
25813         this_obj_conv.inner = (void*)(this_obj & (~1));
25814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25816         CounterpartyForwardingInfo_free(this_obj_conv);
25817 }
25818
25819 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
25820         LDKCounterpartyForwardingInfo this_ptr_conv;
25821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25822         this_ptr_conv.is_owned = false;
25823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25824         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25825         return ret_conv;
25826 }
25827
25828 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25829         LDKCounterpartyForwardingInfo this_ptr_conv;
25830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25831         this_ptr_conv.is_owned = false;
25832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25833         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25834 }
25835
25836 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
25837         LDKCounterpartyForwardingInfo this_ptr_conv;
25838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25839         this_ptr_conv.is_owned = false;
25840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25841         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25842         return ret_conv;
25843 }
25844
25845 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25846         LDKCounterpartyForwardingInfo this_ptr_conv;
25847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25848         this_ptr_conv.is_owned = false;
25849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25850         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25851 }
25852
25853 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
25854         LDKCounterpartyForwardingInfo this_ptr_conv;
25855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25856         this_ptr_conv.is_owned = false;
25857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25858         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25859         return ret_conv;
25860 }
25861
25862 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25863         LDKCounterpartyForwardingInfo this_ptr_conv;
25864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25865         this_ptr_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25867         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25868 }
25869
25870 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) {
25871         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25872         uint32_t ret_ref = 0;
25873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25876         ret_ref = (uintptr_t)ret_var.inner;
25877         if (ret_var.is_owned) {
25878                 ret_ref |= 1;
25879         }
25880         return ret_ref;
25881 }
25882
25883 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25884         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25885 uint32_t ret_ref = 0;
25886 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25887 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25888 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25889 ret_ref = (uintptr_t)ret_var.inner;
25890 if (ret_var.is_owned) {
25891         ret_ref |= 1;
25892 }
25893         return ret_ref;
25894 }
25895 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
25896         LDKCounterpartyForwardingInfo arg_conv;
25897         arg_conv.inner = (void*)(arg & (~1));
25898         arg_conv.is_owned = false;
25899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25900         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25901         return ret_conv;
25902 }
25903
25904 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
25905         LDKCounterpartyForwardingInfo orig_conv;
25906         orig_conv.inner = (void*)(orig & (~1));
25907         orig_conv.is_owned = false;
25908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25909         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25910         uint32_t ret_ref = 0;
25911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25914         ret_ref = (uintptr_t)ret_var.inner;
25915         if (ret_var.is_owned) {
25916                 ret_ref |= 1;
25917         }
25918         return ret_ref;
25919 }
25920
25921 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
25922         LDKChannelCounterparty this_obj_conv;
25923         this_obj_conv.inner = (void*)(this_obj & (~1));
25924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25926         ChannelCounterparty_free(this_obj_conv);
25927 }
25928
25929 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
25930         LDKChannelCounterparty this_ptr_conv;
25931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25932         this_ptr_conv.is_owned = false;
25933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25934         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25935         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25936         return ret_arr;
25937 }
25938
25939 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
25940         LDKChannelCounterparty this_ptr_conv;
25941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25942         this_ptr_conv.is_owned = false;
25943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25944         LDKPublicKey val_ref;
25945         CHECK(val->arr_len == 33);
25946         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25947         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25948 }
25949
25950 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
25951         LDKChannelCounterparty this_ptr_conv;
25952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25953         this_ptr_conv.is_owned = false;
25954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25955         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25956         uint32_t ret_ref = 0;
25957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25960         ret_ref = (uintptr_t)ret_var.inner;
25961         if (ret_var.is_owned) {
25962                 ret_ref |= 1;
25963         }
25964         return ret_ref;
25965 }
25966
25967 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
25968         LDKChannelCounterparty this_ptr_conv;
25969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25970         this_ptr_conv.is_owned = false;
25971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25972         LDKInitFeatures val_conv;
25973         val_conv.inner = (void*)(val & (~1));
25974         val_conv.is_owned = (val & 1) || (val == 0);
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25976         val_conv = InitFeatures_clone(&val_conv);
25977         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
25978 }
25979
25980 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25981         LDKChannelCounterparty this_ptr_conv;
25982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25983         this_ptr_conv.is_owned = false;
25984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25985         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
25986         return ret_conv;
25987 }
25988
25989 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
25990         LDKChannelCounterparty this_ptr_conv;
25991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25992         this_ptr_conv.is_owned = false;
25993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25994         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
25995 }
25996
25997 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
25998         LDKChannelCounterparty this_ptr_conv;
25999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26000         this_ptr_conv.is_owned = false;
26001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26002         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
26003         uint32_t ret_ref = 0;
26004         if ((uintptr_t)ret_var.inner > 4096) {
26005                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26006                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26008                 ret_ref = (uintptr_t)ret_var.inner;
26009                 if (ret_var.is_owned) {
26010                         ret_ref |= 1;
26011                 }
26012         }
26013         return ret_ref;
26014 }
26015
26016 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
26017         LDKChannelCounterparty this_ptr_conv;
26018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26019         this_ptr_conv.is_owned = false;
26020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26021         LDKCounterpartyForwardingInfo val_conv;
26022         val_conv.inner = (void*)(val & (~1));
26023         val_conv.is_owned = (val & 1) || (val == 0);
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26025         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
26026         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
26027 }
26028
26029 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
26030         LDKChannelCounterparty this_ptr_conv;
26031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26032         this_ptr_conv.is_owned = false;
26033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26034         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26035         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
26036         uint32_t ret_ref = (uintptr_t)ret_copy;
26037         return ret_ref;
26038 }
26039
26040 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
26041         LDKChannelCounterparty this_ptr_conv;
26042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26043         this_ptr_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26045         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26046         CHECK_ACCESS(val_ptr);
26047         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26048         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26049         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26050 }
26051
26052 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
26053         LDKChannelCounterparty this_ptr_conv;
26054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26055         this_ptr_conv.is_owned = false;
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26057         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26058         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
26059         uint32_t ret_ref = (uintptr_t)ret_copy;
26060         return ret_ref;
26061 }
26062
26063 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
26064         LDKChannelCounterparty this_ptr_conv;
26065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26066         this_ptr_conv.is_owned = false;
26067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26068         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26069         CHECK_ACCESS(val_ptr);
26070         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26071         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26072         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26073 }
26074
26075 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, uint32_t outbound_htlc_minimum_msat_arg, uint32_t outbound_htlc_maximum_msat_arg) {
26076         LDKPublicKey node_id_arg_ref;
26077         CHECK(node_id_arg->arr_len == 33);
26078         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
26079         LDKInitFeatures features_arg_conv;
26080         features_arg_conv.inner = (void*)(features_arg & (~1));
26081         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26082         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26083         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26084         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
26085         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
26086         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
26087         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
26088         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
26089         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
26090         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
26091         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
26092         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
26093         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
26094         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
26095         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
26096         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
26097         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
26098         uint32_t ret_ref = 0;
26099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26102         ret_ref = (uintptr_t)ret_var.inner;
26103         if (ret_var.is_owned) {
26104                 ret_ref |= 1;
26105         }
26106         return ret_ref;
26107 }
26108
26109 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
26110         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
26111 uint32_t ret_ref = 0;
26112 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26113 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26114 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26115 ret_ref = (uintptr_t)ret_var.inner;
26116 if (ret_var.is_owned) {
26117         ret_ref |= 1;
26118 }
26119         return ret_ref;
26120 }
26121 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
26122         LDKChannelCounterparty arg_conv;
26123         arg_conv.inner = (void*)(arg & (~1));
26124         arg_conv.is_owned = false;
26125         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26126         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
26127         return ret_conv;
26128 }
26129
26130 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
26131         LDKChannelCounterparty orig_conv;
26132         orig_conv.inner = (void*)(orig & (~1));
26133         orig_conv.is_owned = false;
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26135         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
26136         uint32_t ret_ref = 0;
26137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26140         ret_ref = (uintptr_t)ret_var.inner;
26141         if (ret_var.is_owned) {
26142                 ret_ref |= 1;
26143         }
26144         return ret_ref;
26145 }
26146
26147 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
26148         LDKChannelDetails this_obj_conv;
26149         this_obj_conv.inner = (void*)(this_obj & (~1));
26150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26152         ChannelDetails_free(this_obj_conv);
26153 }
26154
26155 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
26156         LDKChannelDetails this_ptr_conv;
26157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26158         this_ptr_conv.is_owned = false;
26159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26160         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26161         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
26162         return ret_arr;
26163 }
26164
26165 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26166         LDKChannelDetails this_ptr_conv;
26167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26168         this_ptr_conv.is_owned = false;
26169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26170         LDKThirtyTwoBytes val_ref;
26171         CHECK(val->arr_len == 32);
26172         memcpy(val_ref.data, val->elems, 32); FREE(val);
26173         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
26174 }
26175
26176 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
26177         LDKChannelDetails this_ptr_conv;
26178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26179         this_ptr_conv.is_owned = false;
26180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26181         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
26182         uint32_t ret_ref = 0;
26183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26186         ret_ref = (uintptr_t)ret_var.inner;
26187         if (ret_var.is_owned) {
26188                 ret_ref |= 1;
26189         }
26190         return ret_ref;
26191 }
26192
26193 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
26194         LDKChannelDetails this_ptr_conv;
26195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26196         this_ptr_conv.is_owned = false;
26197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26198         LDKChannelCounterparty val_conv;
26199         val_conv.inner = (void*)(val & (~1));
26200         val_conv.is_owned = (val & 1) || (val == 0);
26201         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26202         val_conv = ChannelCounterparty_clone(&val_conv);
26203         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
26204 }
26205
26206 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
26207         LDKChannelDetails this_ptr_conv;
26208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26209         this_ptr_conv.is_owned = false;
26210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26211         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
26212         uint32_t ret_ref = 0;
26213         if ((uintptr_t)ret_var.inner > 4096) {
26214                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26215                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26217                 ret_ref = (uintptr_t)ret_var.inner;
26218                 if (ret_var.is_owned) {
26219                         ret_ref |= 1;
26220                 }
26221         }
26222         return ret_ref;
26223 }
26224
26225 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
26226         LDKChannelDetails this_ptr_conv;
26227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26228         this_ptr_conv.is_owned = false;
26229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26230         LDKOutPoint val_conv;
26231         val_conv.inner = (void*)(val & (~1));
26232         val_conv.is_owned = (val & 1) || (val == 0);
26233         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26234         val_conv = OutPoint_clone(&val_conv);
26235         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
26236 }
26237
26238 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
26239         LDKChannelDetails this_ptr_conv;
26240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26241         this_ptr_conv.is_owned = false;
26242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26243         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
26244         uint32_t ret_ref = 0;
26245         if ((uintptr_t)ret_var.inner > 4096) {
26246                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26247                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26249                 ret_ref = (uintptr_t)ret_var.inner;
26250                 if (ret_var.is_owned) {
26251                         ret_ref |= 1;
26252                 }
26253         }
26254         return ret_ref;
26255 }
26256
26257 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
26258         LDKChannelDetails this_ptr_conv;
26259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26260         this_ptr_conv.is_owned = false;
26261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26262         LDKChannelTypeFeatures val_conv;
26263         val_conv.inner = (void*)(val & (~1));
26264         val_conv.is_owned = (val & 1) || (val == 0);
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26266         val_conv = ChannelTypeFeatures_clone(&val_conv);
26267         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
26268 }
26269
26270 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
26271         LDKChannelDetails this_ptr_conv;
26272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26273         this_ptr_conv.is_owned = false;
26274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26275         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26276         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
26277         uint32_t ret_ref = (uintptr_t)ret_copy;
26278         return ret_ref;
26279 }
26280
26281 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
26282         LDKChannelDetails this_ptr_conv;
26283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26284         this_ptr_conv.is_owned = false;
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26286         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26287         CHECK_ACCESS(val_ptr);
26288         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26289         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26290         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
26291 }
26292
26293 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
26294         LDKChannelDetails this_ptr_conv;
26295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26296         this_ptr_conv.is_owned = false;
26297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26298         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26299         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
26300         uint32_t ret_ref = (uintptr_t)ret_copy;
26301         return ret_ref;
26302 }
26303
26304 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26305         LDKChannelDetails this_ptr_conv;
26306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26307         this_ptr_conv.is_owned = false;
26308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26309         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26310         CHECK_ACCESS(val_ptr);
26311         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26312         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26313         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
26314 }
26315
26316 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
26317         LDKChannelDetails this_ptr_conv;
26318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26319         this_ptr_conv.is_owned = false;
26320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26321         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26322         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
26323         uint32_t ret_ref = (uintptr_t)ret_copy;
26324         return ret_ref;
26325 }
26326
26327 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26328         LDKChannelDetails this_ptr_conv;
26329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26330         this_ptr_conv.is_owned = false;
26331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26332         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26333         CHECK_ACCESS(val_ptr);
26334         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26335         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26336         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
26337 }
26338
26339 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
26340         LDKChannelDetails this_ptr_conv;
26341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26342         this_ptr_conv.is_owned = false;
26343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26344         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
26345         return ret_conv;
26346 }
26347
26348 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
26349         LDKChannelDetails this_ptr_conv;
26350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26351         this_ptr_conv.is_owned = false;
26352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26353         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
26354 }
26355
26356 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
26357         LDKChannelDetails this_ptr_conv;
26358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26359         this_ptr_conv.is_owned = false;
26360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26361         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26362         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
26363         uint32_t ret_ref = (uintptr_t)ret_copy;
26364         return ret_ref;
26365 }
26366
26367 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
26368         LDKChannelDetails this_ptr_conv;
26369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26370         this_ptr_conv.is_owned = false;
26371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26372         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26373         CHECK_ACCESS(val_ptr);
26374         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26375         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26376         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
26377 }
26378
26379 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
26380         LDKChannelDetails this_ptr_conv;
26381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26382         this_ptr_conv.is_owned = false;
26383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26384         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
26385         return ret_conv;
26386 }
26387
26388 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
26389         LDKChannelDetails this_ptr_conv;
26390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26391         this_ptr_conv.is_owned = false;
26392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26393         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
26394 }
26395
26396 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
26397         LDKChannelDetails this_ptr_conv;
26398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26399         this_ptr_conv.is_owned = false;
26400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26401         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
26402         return ret_conv;
26403 }
26404
26405 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
26406         LDKChannelDetails this_ptr_conv;
26407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26408         this_ptr_conv.is_owned = false;
26409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26410         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
26411 }
26412
26413 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
26414         LDKChannelDetails this_ptr_conv;
26415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26416         this_ptr_conv.is_owned = false;
26417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26418         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
26419         return ret_conv;
26420 }
26421
26422 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26423         LDKChannelDetails 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         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
26428 }
26429
26430 int64_t  __attribute__((export_name("TS_ChannelDetails_get_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_get_next_outbound_htlc_limit_msat(uint32_t this_ptr) {
26431         LDKChannelDetails this_ptr_conv;
26432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26433         this_ptr_conv.is_owned = false;
26434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26435         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
26436         return ret_conv;
26437 }
26438
26439 void  __attribute__((export_name("TS_ChannelDetails_set_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_set_next_outbound_htlc_limit_msat(uint32_t this_ptr, int64_t val) {
26440         LDKChannelDetails this_ptr_conv;
26441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26442         this_ptr_conv.is_owned = false;
26443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26444         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
26445 }
26446
26447 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
26448         LDKChannelDetails this_ptr_conv;
26449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26450         this_ptr_conv.is_owned = false;
26451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26452         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
26453         return ret_conv;
26454 }
26455
26456 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26457         LDKChannelDetails this_ptr_conv;
26458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26459         this_ptr_conv.is_owned = false;
26460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26461         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
26462 }
26463
26464 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
26465         LDKChannelDetails this_ptr_conv;
26466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26467         this_ptr_conv.is_owned = false;
26468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26469         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26470         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
26471         uint32_t ret_ref = (uintptr_t)ret_copy;
26472         return ret_ref;
26473 }
26474
26475 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
26476         LDKChannelDetails this_ptr_conv;
26477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26478         this_ptr_conv.is_owned = false;
26479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26480         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26481         CHECK_ACCESS(val_ptr);
26482         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26483         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
26484         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
26485 }
26486
26487 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
26488         LDKChannelDetails this_ptr_conv;
26489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26490         this_ptr_conv.is_owned = false;
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26492         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
26493         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
26494         uint32_t ret_ref = (uintptr_t)ret_copy;
26495         return ret_ref;
26496 }
26497
26498 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) {
26499         LDKChannelDetails this_ptr_conv;
26500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26501         this_ptr_conv.is_owned = false;
26502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26503         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26504         CHECK_ACCESS(val_ptr);
26505         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
26506         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
26507         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
26508 }
26509
26510 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
26511         LDKChannelDetails this_ptr_conv;
26512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26513         this_ptr_conv.is_owned = false;
26514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26515         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
26516         return ret_conv;
26517 }
26518
26519 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
26520         LDKChannelDetails this_ptr_conv;
26521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26522         this_ptr_conv.is_owned = false;
26523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26524         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
26525 }
26526
26527 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
26528         LDKChannelDetails this_ptr_conv;
26529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26530         this_ptr_conv.is_owned = false;
26531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26532         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
26533         return ret_conv;
26534 }
26535
26536 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
26537         LDKChannelDetails this_ptr_conv;
26538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26539         this_ptr_conv.is_owned = false;
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26541         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
26542 }
26543
26544 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
26545         LDKChannelDetails this_ptr_conv;
26546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26547         this_ptr_conv.is_owned = false;
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26549         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
26550         return ret_conv;
26551 }
26552
26553 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
26554         LDKChannelDetails this_ptr_conv;
26555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26556         this_ptr_conv.is_owned = false;
26557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26558         ChannelDetails_set_is_usable(&this_ptr_conv, val);
26559 }
26560
26561 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
26562         LDKChannelDetails this_ptr_conv;
26563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26564         this_ptr_conv.is_owned = false;
26565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26566         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
26567         return ret_conv;
26568 }
26569
26570 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
26571         LDKChannelDetails this_ptr_conv;
26572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26573         this_ptr_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26575         ChannelDetails_set_is_public(&this_ptr_conv, val);
26576 }
26577
26578 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
26579         LDKChannelDetails this_ptr_conv;
26580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26581         this_ptr_conv.is_owned = false;
26582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26583         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26584         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
26585         uint32_t ret_ref = (uintptr_t)ret_copy;
26586         return ret_ref;
26587 }
26588
26589 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_minimum_msat"))) TS_ChannelDetails_set_inbound_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
26590         LDKChannelDetails this_ptr_conv;
26591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26592         this_ptr_conv.is_owned = false;
26593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26594         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26595         CHECK_ACCESS(val_ptr);
26596         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26597         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26598         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26599 }
26600
26601 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
26602         LDKChannelDetails this_ptr_conv;
26603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26604         this_ptr_conv.is_owned = false;
26605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26606         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26607         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
26608         uint32_t ret_ref = (uintptr_t)ret_copy;
26609         return ret_ref;
26610 }
26611
26612 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_maximum_msat"))) TS_ChannelDetails_set_inbound_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
26613         LDKChannelDetails this_ptr_conv;
26614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26615         this_ptr_conv.is_owned = false;
26616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26617         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26618         CHECK_ACCESS(val_ptr);
26619         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26620         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26621         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26622 }
26623
26624 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint32_t this_ptr) {
26625         LDKChannelDetails this_ptr_conv;
26626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26627         this_ptr_conv.is_owned = false;
26628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26629         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26630         uint32_t ret_ref = 0;
26631         if ((uintptr_t)ret_var.inner > 4096) {
26632                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26633                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26635                 ret_ref = (uintptr_t)ret_var.inner;
26636                 if (ret_var.is_owned) {
26637                         ret_ref |= 1;
26638                 }
26639         }
26640         return ret_ref;
26641 }
26642
26643 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint32_t this_ptr, uint32_t val) {
26644         LDKChannelDetails 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         LDKChannelConfig val_conv;
26649         val_conv.inner = (void*)(val & (~1));
26650         val_conv.is_owned = (val & 1) || (val == 0);
26651         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26652         val_conv = ChannelConfig_clone(&val_conv);
26653         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26654 }
26655
26656 uint32_t  __attribute__((export_name("TS_ChannelDetails_new"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t channel_type_arg, uint32_t short_channel_id_arg, uint32_t outbound_scid_alias_arg, uint32_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_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_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, uint32_t inbound_htlc_minimum_msat_arg, uint32_t inbound_htlc_maximum_msat_arg, uint32_t config_arg) {
26657         LDKThirtyTwoBytes channel_id_arg_ref;
26658         CHECK(channel_id_arg->arr_len == 32);
26659         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26660         LDKChannelCounterparty counterparty_arg_conv;
26661         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26662         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26663         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26664         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26665         LDKOutPoint funding_txo_arg_conv;
26666         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26667         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26668         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26669         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26670         LDKChannelTypeFeatures channel_type_arg_conv;
26671         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
26672         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
26673         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26674         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26675         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26676         CHECK_ACCESS(short_channel_id_arg_ptr);
26677         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26678         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26679         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
26680         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26681         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26682         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
26683         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
26684         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26685         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26686         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
26687         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26688         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26689         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26690         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26691         CHECK_ACCESS(confirmations_required_arg_ptr);
26692         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26693         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26694         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26695         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26696         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26697         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26698         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
26699         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26700         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26701         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
26702         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
26703         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26704         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26705         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
26706         LDKChannelConfig config_arg_conv;
26707         config_arg_conv.inner = (void*)(config_arg & (~1));
26708         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
26709         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26710         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26711         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
26712         uint32_t ret_ref = 0;
26713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26716         ret_ref = (uintptr_t)ret_var.inner;
26717         if (ret_var.is_owned) {
26718                 ret_ref |= 1;
26719         }
26720         return ret_ref;
26721 }
26722
26723 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26724         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26725 uint32_t ret_ref = 0;
26726 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26727 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26728 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26729 ret_ref = (uintptr_t)ret_var.inner;
26730 if (ret_var.is_owned) {
26731         ret_ref |= 1;
26732 }
26733         return ret_ref;
26734 }
26735 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
26736         LDKChannelDetails arg_conv;
26737         arg_conv.inner = (void*)(arg & (~1));
26738         arg_conv.is_owned = false;
26739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26740         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26741         return ret_conv;
26742 }
26743
26744 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
26745         LDKChannelDetails orig_conv;
26746         orig_conv.inner = (void*)(orig & (~1));
26747         orig_conv.is_owned = false;
26748         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26749         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26750         uint32_t ret_ref = 0;
26751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26754         ret_ref = (uintptr_t)ret_var.inner;
26755         if (ret_var.is_owned) {
26756                 ret_ref |= 1;
26757         }
26758         return ret_ref;
26759 }
26760
26761 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
26762         LDKChannelDetails this_arg_conv;
26763         this_arg_conv.inner = (void*)(this_arg & (~1));
26764         this_arg_conv.is_owned = false;
26765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26766         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26767         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26768         uint32_t ret_ref = (uintptr_t)ret_copy;
26769         return ret_ref;
26770 }
26771
26772 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
26773         LDKChannelDetails this_arg_conv;
26774         this_arg_conv.inner = (void*)(this_arg & (~1));
26775         this_arg_conv.is_owned = false;
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26777         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26778         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26779         uint32_t ret_ref = (uintptr_t)ret_copy;
26780         return ret_ref;
26781 }
26782
26783 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
26784         if ((this_ptr & 1) != 0) return;
26785         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26786         CHECK_ACCESS(this_ptr_ptr);
26787         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26788         FREE((void*)this_ptr);
26789         PaymentSendFailure_free(this_ptr_conv);
26790 }
26791
26792 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26793         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26794         *ret_copy = PaymentSendFailure_clone(arg);
26795 uint32_t ret_ref = (uintptr_t)ret_copy;
26796         return ret_ref;
26797 }
26798 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
26799         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26800         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26801         return ret_conv;
26802 }
26803
26804 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
26805         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26806         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26807         *ret_copy = PaymentSendFailure_clone(orig_conv);
26808         uint32_t ret_ref = (uintptr_t)ret_copy;
26809         return ret_ref;
26810 }
26811
26812 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
26813         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26814         CHECK_ACCESS(a_ptr);
26815         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26816         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26817         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26818         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26819         uint32_t ret_ref = (uintptr_t)ret_copy;
26820         return ret_ref;
26821 }
26822
26823 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
26824         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26825         a_constr.datalen = a->arr_len;
26826         if (a_constr.datalen > 0)
26827                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26828         else
26829                 a_constr.data = NULL;
26830         uint32_t* a_vals = a->elems;
26831         for (size_t w = 0; w < a_constr.datalen; w++) {
26832                 uint32_t a_conv_22 = a_vals[w];
26833                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26834                 CHECK_ACCESS(a_conv_22_ptr);
26835                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26836                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26837                 a_constr.data[w] = a_conv_22_conv;
26838         }
26839         FREE(a);
26840         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26841         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26842         uint32_t ret_ref = (uintptr_t)ret_copy;
26843         return ret_ref;
26844 }
26845
26846 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
26847         LDKCVec_APIErrorZ a_constr;
26848         a_constr.datalen = a->arr_len;
26849         if (a_constr.datalen > 0)
26850                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26851         else
26852                 a_constr.data = NULL;
26853         uint32_t* a_vals = a->elems;
26854         for (size_t k = 0; k < a_constr.datalen; k++) {
26855                 uint32_t a_conv_10 = a_vals[k];
26856                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26857                 CHECK_ACCESS(a_conv_10_ptr);
26858                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26859                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26860                 a_constr.data[k] = a_conv_10_conv;
26861         }
26862         FREE(a);
26863         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26864         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26865         uint32_t ret_ref = (uintptr_t)ret_copy;
26866         return ret_ref;
26867 }
26868
26869 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) {
26870         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26871         results_constr.datalen = results->arr_len;
26872         if (results_constr.datalen > 0)
26873                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26874         else
26875                 results_constr.data = NULL;
26876         uint32_t* results_vals = results->elems;
26877         for (size_t w = 0; w < results_constr.datalen; w++) {
26878                 uint32_t results_conv_22 = results_vals[w];
26879                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26880                 CHECK_ACCESS(results_conv_22_ptr);
26881                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26882                 results_constr.data[w] = results_conv_22_conv;
26883         }
26884         FREE(results);
26885         LDKRouteParameters failed_paths_retry_conv;
26886         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26887         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26888         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26889         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26890         LDKThirtyTwoBytes payment_id_ref;
26891         CHECK(payment_id->arr_len == 32);
26892         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26893         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26894         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26895         uint32_t ret_ref = (uintptr_t)ret_copy;
26896         return ret_ref;
26897 }
26898
26899 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
26900         LDKPhantomRouteHints this_obj_conv;
26901         this_obj_conv.inner = (void*)(this_obj & (~1));
26902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26904         PhantomRouteHints_free(this_obj_conv);
26905 }
26906
26907 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
26908         LDKPhantomRouteHints this_ptr_conv;
26909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26910         this_ptr_conv.is_owned = false;
26911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26912         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26913         uint32_tArray ret_arr = NULL;
26914         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26915         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26916         for (size_t q = 0; q < ret_var.datalen; q++) {
26917                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26918                 uint32_t ret_conv_16_ref = 0;
26919                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26920                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26921                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26922                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26923                 if (ret_conv_16_var.is_owned) {
26924                         ret_conv_16_ref |= 1;
26925                 }
26926                 ret_arr_ptr[q] = ret_conv_16_ref;
26927         }
26928         
26929         FREE(ret_var.data);
26930         return ret_arr;
26931 }
26932
26933 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
26934         LDKPhantomRouteHints this_ptr_conv;
26935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26936         this_ptr_conv.is_owned = false;
26937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26938         LDKCVec_ChannelDetailsZ val_constr;
26939         val_constr.datalen = val->arr_len;
26940         if (val_constr.datalen > 0)
26941                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26942         else
26943                 val_constr.data = NULL;
26944         uint32_t* val_vals = val->elems;
26945         for (size_t q = 0; q < val_constr.datalen; q++) {
26946                 uint32_t val_conv_16 = val_vals[q];
26947                 LDKChannelDetails val_conv_16_conv;
26948                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26949                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26950                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26951                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26952                 val_constr.data[q] = val_conv_16_conv;
26953         }
26954         FREE(val);
26955         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26956 }
26957
26958 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
26959         LDKPhantomRouteHints this_ptr_conv;
26960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26961         this_ptr_conv.is_owned = false;
26962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26963         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26964         return ret_conv;
26965 }
26966
26967 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
26968         LDKPhantomRouteHints this_ptr_conv;
26969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26970         this_ptr_conv.is_owned = false;
26971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26972         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26973 }
26974
26975 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
26976         LDKPhantomRouteHints this_ptr_conv;
26977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26978         this_ptr_conv.is_owned = false;
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26980         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26981         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
26982         return ret_arr;
26983 }
26984
26985 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
26986         LDKPhantomRouteHints this_ptr_conv;
26987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26988         this_ptr_conv.is_owned = false;
26989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26990         LDKPublicKey val_ref;
26991         CHECK(val->arr_len == 33);
26992         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26993         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
26994 }
26995
26996 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) {
26997         LDKCVec_ChannelDetailsZ channels_arg_constr;
26998         channels_arg_constr.datalen = channels_arg->arr_len;
26999         if (channels_arg_constr.datalen > 0)
27000                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27001         else
27002                 channels_arg_constr.data = NULL;
27003         uint32_t* channels_arg_vals = channels_arg->elems;
27004         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
27005                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
27006                 LDKChannelDetails channels_arg_conv_16_conv;
27007                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
27008                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
27009                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
27010                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
27011                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
27012         }
27013         FREE(channels_arg);
27014         LDKPublicKey real_node_pubkey_arg_ref;
27015         CHECK(real_node_pubkey_arg->arr_len == 33);
27016         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
27017         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
27018         uint32_t ret_ref = 0;
27019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27022         ret_ref = (uintptr_t)ret_var.inner;
27023         if (ret_var.is_owned) {
27024                 ret_ref |= 1;
27025         }
27026         return ret_ref;
27027 }
27028
27029 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
27030         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
27031 uint32_t ret_ref = 0;
27032 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27033 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27034 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27035 ret_ref = (uintptr_t)ret_var.inner;
27036 if (ret_var.is_owned) {
27037         ret_ref |= 1;
27038 }
27039         return ret_ref;
27040 }
27041 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
27042         LDKPhantomRouteHints arg_conv;
27043         arg_conv.inner = (void*)(arg & (~1));
27044         arg_conv.is_owned = false;
27045         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27046         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
27047         return ret_conv;
27048 }
27049
27050 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
27051         LDKPhantomRouteHints orig_conv;
27052         orig_conv.inner = (void*)(orig & (~1));
27053         orig_conv.is_owned = false;
27054         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27055         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
27056         uint32_t ret_ref = 0;
27057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27060         ret_ref = (uintptr_t)ret_var.inner;
27061         if (ret_var.is_owned) {
27062                 ret_ref |= 1;
27063         }
27064         return ret_ref;
27065 }
27066
27067 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) {
27068         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
27069         CHECK_ACCESS(fee_est_ptr);
27070         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
27071         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
27072                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27073                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
27074         }
27075         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27076         CHECK_ACCESS(chain_monitor_ptr);
27077         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27078         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27079                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27080                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27081         }
27082         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27083         CHECK_ACCESS(tx_broadcaster_ptr);
27084         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27085         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27087                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27088         }
27089         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27090         CHECK_ACCESS(logger_ptr);
27091         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27092         if (logger_conv.free == LDKLogger_JCalls_free) {
27093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27094                 LDKLogger_JCalls_cloned(&logger_conv);
27095         }
27096         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27097         CHECK_ACCESS(keys_manager_ptr);
27098         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27099         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27101                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27102         }
27103         LDKUserConfig config_conv;
27104         config_conv.inner = (void*)(config & (~1));
27105         config_conv.is_owned = (config & 1) || (config == 0);
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27107         config_conv = UserConfig_clone(&config_conv);
27108         LDKChainParameters params_conv;
27109         params_conv.inner = (void*)(params & (~1));
27110         params_conv.is_owned = (params & 1) || (params == 0);
27111         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
27112         params_conv = ChainParameters_clone(&params_conv);
27113         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
27114         uint32_t ret_ref = 0;
27115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27118         ret_ref = (uintptr_t)ret_var.inner;
27119         if (ret_var.is_owned) {
27120                 ret_ref |= 1;
27121         }
27122         return ret_ref;
27123 }
27124
27125 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
27126         LDKChannelManager this_arg_conv;
27127         this_arg_conv.inner = (void*)(this_arg & (~1));
27128         this_arg_conv.is_owned = false;
27129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27130         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
27131         uint32_t ret_ref = 0;
27132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27135         ret_ref = (uintptr_t)ret_var.inner;
27136         if (ret_var.is_owned) {
27137                 ret_ref |= 1;
27138         }
27139         return ret_ref;
27140 }
27141
27142 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) {
27143         LDKChannelManager this_arg_conv;
27144         this_arg_conv.inner = (void*)(this_arg & (~1));
27145         this_arg_conv.is_owned = false;
27146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27147         LDKPublicKey their_network_key_ref;
27148         CHECK(their_network_key->arr_len == 33);
27149         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
27150         LDKUserConfig override_config_conv;
27151         override_config_conv.inner = (void*)(override_config & (~1));
27152         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
27153         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
27154         override_config_conv = UserConfig_clone(&override_config_conv);
27155         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
27156         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
27157         return (uint32_t)ret_conv;
27158 }
27159
27160 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
27161         LDKChannelManager this_arg_conv;
27162         this_arg_conv.inner = (void*)(this_arg & (~1));
27163         this_arg_conv.is_owned = false;
27164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27165         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
27166         uint32_tArray ret_arr = NULL;
27167         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27168         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27169         for (size_t q = 0; q < ret_var.datalen; q++) {
27170                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27171                 uint32_t ret_conv_16_ref = 0;
27172                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27173                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27175                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27176                 if (ret_conv_16_var.is_owned) {
27177                         ret_conv_16_ref |= 1;
27178                 }
27179                 ret_arr_ptr[q] = ret_conv_16_ref;
27180         }
27181         
27182         FREE(ret_var.data);
27183         return ret_arr;
27184 }
27185
27186 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
27187         LDKChannelManager this_arg_conv;
27188         this_arg_conv.inner = (void*)(this_arg & (~1));
27189         this_arg_conv.is_owned = false;
27190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27191         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
27192         uint32_tArray ret_arr = NULL;
27193         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27194         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27195         for (size_t q = 0; q < ret_var.datalen; q++) {
27196                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27197                 uint32_t ret_conv_16_ref = 0;
27198                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27199                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27200                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27201                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27202                 if (ret_conv_16_var.is_owned) {
27203                         ret_conv_16_ref |= 1;
27204                 }
27205                 ret_arr_ptr[q] = ret_conv_16_ref;
27206         }
27207         
27208         FREE(ret_var.data);
27209         return ret_arr;
27210 }
27211
27212 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27213         LDKChannelManager this_arg_conv;
27214         this_arg_conv.inner = (void*)(this_arg & (~1));
27215         this_arg_conv.is_owned = false;
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27217         unsigned char channel_id_arr[32];
27218         CHECK(channel_id->arr_len == 32);
27219         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27220         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27221         LDKPublicKey counterparty_node_id_ref;
27222         CHECK(counterparty_node_id->arr_len == 33);
27223         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27224         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27225         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27226         return (uint32_t)ret_conv;
27227 }
27228
27229 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, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
27230         LDKChannelManager this_arg_conv;
27231         this_arg_conv.inner = (void*)(this_arg & (~1));
27232         this_arg_conv.is_owned = false;
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27234         unsigned char channel_id_arr[32];
27235         CHECK(channel_id->arr_len == 32);
27236         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27237         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27238         LDKPublicKey counterparty_node_id_ref;
27239         CHECK(counterparty_node_id->arr_len == 33);
27240         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27241         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27242         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
27243         return (uint32_t)ret_conv;
27244 }
27245
27246 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_broadcasting_latest_txn"))) TS_ChannelManager_force_close_broadcasting_latest_txn(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27247         LDKChannelManager this_arg_conv;
27248         this_arg_conv.inner = (void*)(this_arg & (~1));
27249         this_arg_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27251         unsigned char channel_id_arr[32];
27252         CHECK(channel_id->arr_len == 32);
27253         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27254         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27255         LDKPublicKey counterparty_node_id_ref;
27256         CHECK(counterparty_node_id->arr_len == 33);
27257         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27258         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27259         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27260         return (uint32_t)ret_conv;
27261 }
27262
27263 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_without_broadcasting_txn"))) TS_ChannelManager_force_close_without_broadcasting_txn(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27264         LDKChannelManager this_arg_conv;
27265         this_arg_conv.inner = (void*)(this_arg & (~1));
27266         this_arg_conv.is_owned = false;
27267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27268         unsigned char channel_id_arr[32];
27269         CHECK(channel_id->arr_len == 32);
27270         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27271         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27272         LDKPublicKey counterparty_node_id_ref;
27273         CHECK(counterparty_node_id->arr_len == 33);
27274         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27275         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27276         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27277         return (uint32_t)ret_conv;
27278 }
27279
27280 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn"))) TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn(uint32_t this_arg) {
27281         LDKChannelManager this_arg_conv;
27282         this_arg_conv.inner = (void*)(this_arg & (~1));
27283         this_arg_conv.is_owned = false;
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27285         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
27286 }
27287
27288 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_without_broadcasting_txn"))) TS_ChannelManager_force_close_all_channels_without_broadcasting_txn(uint32_t this_arg) {
27289         LDKChannelManager this_arg_conv;
27290         this_arg_conv.inner = (void*)(this_arg & (~1));
27291         this_arg_conv.is_owned = false;
27292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27293         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
27294 }
27295
27296 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) {
27297         LDKChannelManager this_arg_conv;
27298         this_arg_conv.inner = (void*)(this_arg & (~1));
27299         this_arg_conv.is_owned = false;
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27301         LDKRoute route_conv;
27302         route_conv.inner = (void*)(route & (~1));
27303         route_conv.is_owned = false;
27304         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27305         LDKThirtyTwoBytes payment_hash_ref;
27306         CHECK(payment_hash->arr_len == 32);
27307         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27308         LDKThirtyTwoBytes payment_secret_ref;
27309         CHECK(payment_secret->arr_len == 32);
27310         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27311         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
27312         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
27313         return (uint32_t)ret_conv;
27314 }
27315
27316 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
27317         LDKChannelManager this_arg_conv;
27318         this_arg_conv.inner = (void*)(this_arg & (~1));
27319         this_arg_conv.is_owned = false;
27320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27321         LDKRoute route_conv;
27322         route_conv.inner = (void*)(route & (~1));
27323         route_conv.is_owned = false;
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27325         LDKThirtyTwoBytes payment_id_ref;
27326         CHECK(payment_id->arr_len == 32);
27327         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27328         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
27329         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
27330         return (uint32_t)ret_conv;
27331 }
27332
27333 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
27334         LDKChannelManager this_arg_conv;
27335         this_arg_conv.inner = (void*)(this_arg & (~1));
27336         this_arg_conv.is_owned = false;
27337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27338         LDKThirtyTwoBytes payment_id_ref;
27339         CHECK(payment_id->arr_len == 32);
27340         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27341         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
27342 }
27343
27344 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) {
27345         LDKChannelManager this_arg_conv;
27346         this_arg_conv.inner = (void*)(this_arg & (~1));
27347         this_arg_conv.is_owned = false;
27348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27349         LDKRoute route_conv;
27350         route_conv.inner = (void*)(route & (~1));
27351         route_conv.is_owned = false;
27352         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27353         LDKThirtyTwoBytes payment_preimage_ref;
27354         CHECK(payment_preimage->arr_len == 32);
27355         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27356         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27357         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
27358         return (uint32_t)ret_conv;
27359 }
27360
27361 uint32_t  __attribute__((export_name("TS_ChannelManager_send_probe"))) TS_ChannelManager_send_probe(uint32_t this_arg, uint32_tArray hops) {
27362         LDKChannelManager this_arg_conv;
27363         this_arg_conv.inner = (void*)(this_arg & (~1));
27364         this_arg_conv.is_owned = false;
27365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27366         LDKCVec_RouteHopZ hops_constr;
27367         hops_constr.datalen = hops->arr_len;
27368         if (hops_constr.datalen > 0)
27369                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27370         else
27371                 hops_constr.data = NULL;
27372         uint32_t* hops_vals = hops->elems;
27373         for (size_t k = 0; k < hops_constr.datalen; k++) {
27374                 uint32_t hops_conv_10 = hops_vals[k];
27375                 LDKRouteHop hops_conv_10_conv;
27376                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
27377                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
27378                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
27379                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
27380                 hops_constr.data[k] = hops_conv_10_conv;
27381         }
27382         FREE(hops);
27383         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27384         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
27385         return (uint32_t)ret_conv;
27386 }
27387
27388 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 counterparty_node_id, int8_tArray funding_transaction) {
27389         LDKChannelManager this_arg_conv;
27390         this_arg_conv.inner = (void*)(this_arg & (~1));
27391         this_arg_conv.is_owned = false;
27392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27393         unsigned char temporary_channel_id_arr[32];
27394         CHECK(temporary_channel_id->arr_len == 32);
27395         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27396         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27397         LDKPublicKey counterparty_node_id_ref;
27398         CHECK(counterparty_node_id->arr_len == 33);
27399         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27400         LDKTransaction funding_transaction_ref;
27401         funding_transaction_ref.datalen = funding_transaction->arr_len;
27402         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
27403         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
27404         funding_transaction_ref.data_is_owned = true;
27405         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27406         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
27407         return (uint32_t)ret_conv;
27408 }
27409
27410 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) {
27411         LDKChannelManager this_arg_conv;
27412         this_arg_conv.inner = (void*)(this_arg & (~1));
27413         this_arg_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27415         LDKThreeBytes rgb_ref;
27416         CHECK(rgb->arr_len == 3);
27417         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
27418         LDKThirtyTwoBytes alias_ref;
27419         CHECK(alias->arr_len == 32);
27420         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
27421         LDKCVec_NetAddressZ addresses_constr;
27422         addresses_constr.datalen = addresses->arr_len;
27423         if (addresses_constr.datalen > 0)
27424                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
27425         else
27426                 addresses_constr.data = NULL;
27427         uint32_t* addresses_vals = addresses->elems;
27428         for (size_t m = 0; m < addresses_constr.datalen; m++) {
27429                 uint32_t addresses_conv_12 = addresses_vals[m];
27430                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
27431                 CHECK_ACCESS(addresses_conv_12_ptr);
27432                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
27433                 addresses_constr.data[m] = addresses_conv_12_conv;
27434         }
27435         FREE(addresses);
27436         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
27437 }
27438
27439 uint32_t  __attribute__((export_name("TS_ChannelManager_update_channel_config"))) TS_ChannelManager_update_channel_config(uint32_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, uint32_t config) {
27440         LDKChannelManager this_arg_conv;
27441         this_arg_conv.inner = (void*)(this_arg & (~1));
27442         this_arg_conv.is_owned = false;
27443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27444         LDKPublicKey counterparty_node_id_ref;
27445         CHECK(counterparty_node_id->arr_len == 33);
27446         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27447         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
27448         channel_ids_constr.datalen = channel_ids->arr_len;
27449         if (channel_ids_constr.datalen > 0)
27450                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
27451         else
27452                 channel_ids_constr.data = NULL;
27453         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
27454         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
27455                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
27456                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
27457                 CHECK(channel_ids_conv_12->arr_len == 32);
27458                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
27459                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
27460         }
27461         FREE(channel_ids);
27462         LDKChannelConfig config_conv;
27463         config_conv.inner = (void*)(config & (~1));
27464         config_conv.is_owned = false;
27465         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27466         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27467         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
27468         return (uint32_t)ret_conv;
27469 }
27470
27471 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
27472         LDKChannelManager this_arg_conv;
27473         this_arg_conv.inner = (void*)(this_arg & (~1));
27474         this_arg_conv.is_owned = false;
27475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27476         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
27477 }
27478
27479 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
27480         LDKChannelManager this_arg_conv;
27481         this_arg_conv.inner = (void*)(this_arg & (~1));
27482         this_arg_conv.is_owned = false;
27483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27484         ChannelManager_timer_tick_occurred(&this_arg_conv);
27485 }
27486
27487 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
27488         LDKChannelManager this_arg_conv;
27489         this_arg_conv.inner = (void*)(this_arg & (~1));
27490         this_arg_conv.is_owned = false;
27491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27492         unsigned char payment_hash_arr[32];
27493         CHECK(payment_hash->arr_len == 32);
27494         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
27495         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
27496         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
27497 }
27498
27499 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
27500         LDKChannelManager this_arg_conv;
27501         this_arg_conv.inner = (void*)(this_arg & (~1));
27502         this_arg_conv.is_owned = false;
27503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27504         LDKThirtyTwoBytes payment_preimage_ref;
27505         CHECK(payment_preimage->arr_len == 32);
27506         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27507         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
27508 }
27509
27510 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
27511         LDKChannelManager this_arg_conv;
27512         this_arg_conv.inner = (void*)(this_arg & (~1));
27513         this_arg_conv.is_owned = false;
27514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27516         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
27517         return ret_arr;
27518 }
27519
27520 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27521         LDKChannelManager this_arg_conv;
27522         this_arg_conv.inner = (void*)(this_arg & (~1));
27523         this_arg_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27525         unsigned char temporary_channel_id_arr[32];
27526         CHECK(temporary_channel_id->arr_len == 32);
27527         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27528         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27529         LDKPublicKey counterparty_node_id_ref;
27530         CHECK(counterparty_node_id->arr_len == 33);
27531         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27532         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27533         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27534         return (uint32_t)ret_conv;
27535 }
27536
27537 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf"))) TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27538         LDKChannelManager this_arg_conv;
27539         this_arg_conv.inner = (void*)(this_arg & (~1));
27540         this_arg_conv.is_owned = false;
27541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27542         unsigned char temporary_channel_id_arr[32];
27543         CHECK(temporary_channel_id->arr_len == 32);
27544         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27545         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27546         LDKPublicKey counterparty_node_id_ref;
27547         CHECK(counterparty_node_id->arr_len == 33);
27548         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27549         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27550         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27551         return (uint32_t)ret_conv;
27552 }
27553
27554 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) {
27555         LDKChannelManager this_arg_conv;
27556         this_arg_conv.inner = (void*)(this_arg & (~1));
27557         this_arg_conv.is_owned = false;
27558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27559         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27560         CHECK_ACCESS(min_value_msat_ptr);
27561         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27562         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27563         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27564         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27565         return (uint32_t)ret_conv;
27566 }
27567
27568 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) {
27569         LDKChannelManager this_arg_conv;
27570         this_arg_conv.inner = (void*)(this_arg & (~1));
27571         this_arg_conv.is_owned = false;
27572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27573         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27574         CHECK_ACCESS(min_value_msat_ptr);
27575         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27576         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27577         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
27578         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27579         return (uint32_t)ret_conv;
27580 }
27581
27582 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) {
27583         LDKChannelManager this_arg_conv;
27584         this_arg_conv.inner = (void*)(this_arg & (~1));
27585         this_arg_conv.is_owned = false;
27586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27587         LDKThirtyTwoBytes payment_hash_ref;
27588         CHECK(payment_hash->arr_len == 32);
27589         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27590         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27591         CHECK_ACCESS(min_value_msat_ptr);
27592         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27593         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27594         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27595         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27596         return (uint32_t)ret_conv;
27597 }
27598
27599 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) {
27600         LDKChannelManager this_arg_conv;
27601         this_arg_conv.inner = (void*)(this_arg & (~1));
27602         this_arg_conv.is_owned = false;
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27604         LDKThirtyTwoBytes payment_hash_ref;
27605         CHECK(payment_hash->arr_len == 32);
27606         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27607         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27608         CHECK_ACCESS(min_value_msat_ptr);
27609         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27610         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27611         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
27612         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27613         return (uint32_t)ret_conv;
27614 }
27615
27616 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) {
27617         LDKChannelManager this_arg_conv;
27618         this_arg_conv.inner = (void*)(this_arg & (~1));
27619         this_arg_conv.is_owned = false;
27620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27621         LDKThirtyTwoBytes payment_hash_ref;
27622         CHECK(payment_hash->arr_len == 32);
27623         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27624         LDKThirtyTwoBytes payment_secret_ref;
27625         CHECK(payment_secret->arr_len == 32);
27626         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27627         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
27628         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
27629         return (uint32_t)ret_conv;
27630 }
27631
27632 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
27633         LDKChannelManager this_arg_conv;
27634         this_arg_conv.inner = (void*)(this_arg & (~1));
27635         this_arg_conv.is_owned = false;
27636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27637         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
27638         return ret_conv;
27639 }
27640
27641 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
27642         LDKChannelManager this_arg_conv;
27643         this_arg_conv.inner = (void*)(this_arg & (~1));
27644         this_arg_conv.is_owned = false;
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27646         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27647         uint32_t ret_ref = 0;
27648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27651         ret_ref = (uintptr_t)ret_var.inner;
27652         if (ret_var.is_owned) {
27653                 ret_ref |= 1;
27654         }
27655         return ret_ref;
27656 }
27657
27658 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
27659         LDKChannelManager this_arg_conv;
27660         this_arg_conv.inner = (void*)(this_arg & (~1));
27661         this_arg_conv.is_owned = false;
27662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27663         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27664         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27665         return (uint32_t)ret_ret;
27666 }
27667
27668 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
27669         LDKChannelManager this_arg_conv;
27670         this_arg_conv.inner = (void*)(this_arg & (~1));
27671         this_arg_conv.is_owned = false;
27672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27673         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27674         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27675         return (uint32_t)ret_ret;
27676 }
27677
27678 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
27679         LDKChannelManager this_arg_conv;
27680         this_arg_conv.inner = (void*)(this_arg & (~1));
27681         this_arg_conv.is_owned = false;
27682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27683         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27684         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27685         return (uint32_t)ret_ret;
27686 }
27687
27688 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
27689         LDKChannelManager this_arg_conv;
27690         this_arg_conv.inner = (void*)(this_arg & (~1));
27691         this_arg_conv.is_owned = false;
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27693         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27694         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27695         return (uint32_t)ret_ret;
27696 }
27697
27698 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
27699         LDKChannelManager this_arg_conv;
27700         this_arg_conv.inner = (void*)(this_arg & (~1));
27701         this_arg_conv.is_owned = false;
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27703         ChannelManager_await_persistable_update(&this_arg_conv);
27704 }
27705
27706 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
27707         LDKChannelManager this_arg_conv;
27708         this_arg_conv.inner = (void*)(this_arg & (~1));
27709         this_arg_conv.is_owned = false;
27710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27711         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27712         uint32_t ret_ref = 0;
27713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27716         ret_ref = (uintptr_t)ret_var.inner;
27717         if (ret_var.is_owned) {
27718                 ret_ref |= 1;
27719         }
27720         return ret_ref;
27721 }
27722
27723 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
27724         LDKChannelManager this_arg_conv;
27725         this_arg_conv.inner = (void*)(this_arg & (~1));
27726         this_arg_conv.is_owned = false;
27727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27728         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27729         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27730         return (uint32_t)ret_ret;
27731 }
27732
27733 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
27734         LDKCounterpartyForwardingInfo obj_conv;
27735         obj_conv.inner = (void*)(obj & (~1));
27736         obj_conv.is_owned = false;
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27738         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27739         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27740         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27741         CVec_u8Z_free(ret_var);
27742         return ret_arr;
27743 }
27744
27745 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27746         LDKu8slice ser_ref;
27747         ser_ref.datalen = ser->arr_len;
27748         ser_ref.data = ser->elems;
27749         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27750         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27751         FREE(ser);
27752         return (uint32_t)ret_conv;
27753 }
27754
27755 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
27756         LDKChannelCounterparty obj_conv;
27757         obj_conv.inner = (void*)(obj & (~1));
27758         obj_conv.is_owned = false;
27759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27760         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27763         CVec_u8Z_free(ret_var);
27764         return ret_arr;
27765 }
27766
27767 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27768         LDKu8slice ser_ref;
27769         ser_ref.datalen = ser->arr_len;
27770         ser_ref.data = ser->elems;
27771         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27772         *ret_conv = ChannelCounterparty_read(ser_ref);
27773         FREE(ser);
27774         return (uint32_t)ret_conv;
27775 }
27776
27777 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
27778         LDKChannelDetails obj_conv;
27779         obj_conv.inner = (void*)(obj & (~1));
27780         obj_conv.is_owned = false;
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27782         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27785         CVec_u8Z_free(ret_var);
27786         return ret_arr;
27787 }
27788
27789 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27790         LDKu8slice ser_ref;
27791         ser_ref.datalen = ser->arr_len;
27792         ser_ref.data = ser->elems;
27793         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27794         *ret_conv = ChannelDetails_read(ser_ref);
27795         FREE(ser);
27796         return (uint32_t)ret_conv;
27797 }
27798
27799 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
27800         LDKPhantomRouteHints obj_conv;
27801         obj_conv.inner = (void*)(obj & (~1));
27802         obj_conv.is_owned = false;
27803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27804         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27807         CVec_u8Z_free(ret_var);
27808         return ret_arr;
27809 }
27810
27811 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27812         LDKu8slice ser_ref;
27813         ser_ref.datalen = ser->arr_len;
27814         ser_ref.data = ser->elems;
27815         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27816         *ret_conv = PhantomRouteHints_read(ser_ref);
27817         FREE(ser);
27818         return (uint32_t)ret_conv;
27819 }
27820
27821 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
27822         LDKChannelManager obj_conv;
27823         obj_conv.inner = (void*)(obj & (~1));
27824         obj_conv.is_owned = false;
27825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27826         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27827         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27828         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27829         CVec_u8Z_free(ret_var);
27830         return ret_arr;
27831 }
27832
27833 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
27834         LDKChannelManagerReadArgs this_obj_conv;
27835         this_obj_conv.inner = (void*)(this_obj & (~1));
27836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27838         ChannelManagerReadArgs_free(this_obj_conv);
27839 }
27840
27841 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
27842         LDKChannelManagerReadArgs this_ptr_conv;
27843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27844         this_ptr_conv.is_owned = false;
27845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27846         // WARNING: This object doesn't live past this scope, needs clone!
27847         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27848         return ret_ret;
27849 }
27850
27851 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
27852         LDKChannelManagerReadArgs this_ptr_conv;
27853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27854         this_ptr_conv.is_owned = false;
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27856         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27857         CHECK_ACCESS(val_ptr);
27858         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27859         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27861                 LDKKeysInterface_JCalls_cloned(&val_conv);
27862         }
27863         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27864 }
27865
27866 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
27867         LDKChannelManagerReadArgs this_ptr_conv;
27868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27869         this_ptr_conv.is_owned = false;
27870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27871         // WARNING: This object doesn't live past this scope, needs clone!
27872         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27873         return ret_ret;
27874 }
27875
27876 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
27877         LDKChannelManagerReadArgs this_ptr_conv;
27878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27879         this_ptr_conv.is_owned = false;
27880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27881         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27882         CHECK_ACCESS(val_ptr);
27883         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27884         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27886                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27887         }
27888         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27889 }
27890
27891 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
27892         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
27897         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27898         return ret_ret;
27899 }
27900
27901 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
27902         LDKChannelManagerReadArgs this_ptr_conv;
27903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27904         this_ptr_conv.is_owned = false;
27905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27906         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27907         CHECK_ACCESS(val_ptr);
27908         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27909         if (val_conv.free == LDKWatch_JCalls_free) {
27910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27911                 LDKWatch_JCalls_cloned(&val_conv);
27912         }
27913         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27914 }
27915
27916 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
27917         LDKChannelManagerReadArgs this_ptr_conv;
27918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27919         this_ptr_conv.is_owned = false;
27920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27921         // WARNING: This object doesn't live past this scope, needs clone!
27922         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27923         return ret_ret;
27924 }
27925
27926 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
27927         LDKChannelManagerReadArgs this_ptr_conv;
27928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27929         this_ptr_conv.is_owned = false;
27930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27931         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27932         CHECK_ACCESS(val_ptr);
27933         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27934         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27936                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27937         }
27938         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27939 }
27940
27941 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
27942         LDKChannelManagerReadArgs this_ptr_conv;
27943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27944         this_ptr_conv.is_owned = false;
27945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27946         // WARNING: This object doesn't live past this scope, needs clone!
27947         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27948         return ret_ret;
27949 }
27950
27951 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
27952         LDKChannelManagerReadArgs this_ptr_conv;
27953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27954         this_ptr_conv.is_owned = false;
27955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27956         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27957         CHECK_ACCESS(val_ptr);
27958         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27959         if (val_conv.free == LDKLogger_JCalls_free) {
27960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27961                 LDKLogger_JCalls_cloned(&val_conv);
27962         }
27963         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27964 }
27965
27966 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
27967         LDKChannelManagerReadArgs 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         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27972         uint32_t ret_ref = 0;
27973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27976         ret_ref = (uintptr_t)ret_var.inner;
27977         if (ret_var.is_owned) {
27978                 ret_ref |= 1;
27979         }
27980         return ret_ref;
27981 }
27982
27983 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
27984         LDKChannelManagerReadArgs 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         LDKUserConfig val_conv;
27989         val_conv.inner = (void*)(val & (~1));
27990         val_conv.is_owned = (val & 1) || (val == 0);
27991         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27992         val_conv = UserConfig_clone(&val_conv);
27993         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
27994 }
27995
27996 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) {
27997         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27998         CHECK_ACCESS(keys_manager_ptr);
27999         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28000         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28002                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28003         }
28004         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
28005         CHECK_ACCESS(fee_estimator_ptr);
28006         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28007         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28008                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28009                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28010         }
28011         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28012         CHECK_ACCESS(chain_monitor_ptr);
28013         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28014         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28015                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28016                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28017         }
28018         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28019         CHECK_ACCESS(tx_broadcaster_ptr);
28020         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28021         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28022                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28023                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28024         }
28025         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28026         CHECK_ACCESS(logger_ptr);
28027         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28028         if (logger_conv.free == LDKLogger_JCalls_free) {
28029                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28030                 LDKLogger_JCalls_cloned(&logger_conv);
28031         }
28032         LDKUserConfig default_config_conv;
28033         default_config_conv.inner = (void*)(default_config & (~1));
28034         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
28036         default_config_conv = UserConfig_clone(&default_config_conv);
28037         LDKCVec_ChannelMonitorZ channel_monitors_constr;
28038         channel_monitors_constr.datalen = channel_monitors->arr_len;
28039         if (channel_monitors_constr.datalen > 0)
28040                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
28041         else
28042                 channel_monitors_constr.data = NULL;
28043         uint32_t* channel_monitors_vals = channel_monitors->elems;
28044         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
28045                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
28046                 LDKChannelMonitor channel_monitors_conv_16_conv;
28047                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
28048                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
28049                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
28050                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
28051         }
28052         FREE(channel_monitors);
28053         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);
28054         uint32_t ret_ref = 0;
28055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28058         ret_ref = (uintptr_t)ret_var.inner;
28059         if (ret_var.is_owned) {
28060                 ret_ref |= 1;
28061         }
28062         return ret_ref;
28063 }
28064
28065 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
28066         LDKu8slice ser_ref;
28067         ser_ref.datalen = ser->arr_len;
28068         ser_ref.data = ser->elems;
28069         LDKChannelManagerReadArgs arg_conv;
28070         arg_conv.inner = (void*)(arg & (~1));
28071         arg_conv.is_owned = (arg & 1) || (arg == 0);
28072         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28073         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
28074         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
28075         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
28076         FREE(ser);
28077         return (uint32_t)ret_conv;
28078 }
28079
28080 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
28081         LDKExpandedKey this_obj_conv;
28082         this_obj_conv.inner = (void*)(this_obj & (~1));
28083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28085         ExpandedKey_free(this_obj_conv);
28086 }
28087
28088 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
28089         unsigned char key_material_arr[32];
28090         CHECK(key_material->arr_len == 32);
28091         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
28092         unsigned char (*key_material_ref)[32] = &key_material_arr;
28093         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
28094         uint32_t ret_ref = 0;
28095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28098         ret_ref = (uintptr_t)ret_var.inner;
28099         if (ret_var.is_owned) {
28100                 ret_ref |= 1;
28101         }
28102         return ret_ref;
28103 }
28104
28105 uint32_t  __attribute__((export_name("TS_create"))) TS_create(uint32_t keys, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, uint32_t keys_manager, int64_t current_time) {
28106         LDKExpandedKey keys_conv;
28107         keys_conv.inner = (void*)(keys & (~1));
28108         keys_conv.is_owned = false;
28109         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28110         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28111         CHECK_ACCESS(min_value_msat_ptr);
28112         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28113         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28114         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28115         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
28116         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
28117         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28118         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
28119         return (uint32_t)ret_conv;
28120 }
28121
28122 uint32_t  __attribute__((export_name("TS_create_from_hash"))) TS_create_from_hash(uint32_t keys, uint32_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
28123         LDKExpandedKey keys_conv;
28124         keys_conv.inner = (void*)(keys & (~1));
28125         keys_conv.is_owned = false;
28126         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28127         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28128         CHECK_ACCESS(min_value_msat_ptr);
28129         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28130         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28131         LDKThirtyTwoBytes payment_hash_ref;
28132         CHECK(payment_hash->arr_len == 32);
28133         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
28134         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28135         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
28136         return (uint32_t)ret_conv;
28137 }
28138
28139 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
28140         LDKDecodeError this_obj_conv;
28141         this_obj_conv.inner = (void*)(this_obj & (~1));
28142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28144         DecodeError_free(this_obj_conv);
28145 }
28146
28147 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
28148         LDKDecodeError ret_var = DecodeError_clone(arg);
28149 uint32_t ret_ref = 0;
28150 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28151 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28152 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28153 ret_ref = (uintptr_t)ret_var.inner;
28154 if (ret_var.is_owned) {
28155         ret_ref |= 1;
28156 }
28157         return ret_ref;
28158 }
28159 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
28160         LDKDecodeError arg_conv;
28161         arg_conv.inner = (void*)(arg & (~1));
28162         arg_conv.is_owned = false;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28164         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
28165         return ret_conv;
28166 }
28167
28168 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
28169         LDKDecodeError orig_conv;
28170         orig_conv.inner = (void*)(orig & (~1));
28171         orig_conv.is_owned = false;
28172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28173         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
28174         uint32_t ret_ref = 0;
28175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28178         ret_ref = (uintptr_t)ret_var.inner;
28179         if (ret_var.is_owned) {
28180                 ret_ref |= 1;
28181         }
28182         return ret_ref;
28183 }
28184
28185 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
28186         LDKInit this_obj_conv;
28187         this_obj_conv.inner = (void*)(this_obj & (~1));
28188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28190         Init_free(this_obj_conv);
28191 }
28192
28193 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
28194         LDKInit this_ptr_conv;
28195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28196         this_ptr_conv.is_owned = false;
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28198         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
28199         uint32_t ret_ref = 0;
28200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28203         ret_ref = (uintptr_t)ret_var.inner;
28204         if (ret_var.is_owned) {
28205                 ret_ref |= 1;
28206         }
28207         return ret_ref;
28208 }
28209
28210 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
28211         LDKInit 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         LDKInitFeatures val_conv;
28216         val_conv.inner = (void*)(val & (~1));
28217         val_conv.is_owned = (val & 1) || (val == 0);
28218         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28219         val_conv = InitFeatures_clone(&val_conv);
28220         Init_set_features(&this_ptr_conv, val_conv);
28221 }
28222
28223 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
28224         LDKInit this_ptr_conv;
28225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28226         this_ptr_conv.is_owned = false;
28227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28228         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
28229         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
28230         uint32_t ret_ref = (uintptr_t)ret_copy;
28231         return ret_ref;
28232 }
28233
28234 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
28235         LDKInit this_ptr_conv;
28236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28237         this_ptr_conv.is_owned = false;
28238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28239         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28240         CHECK_ACCESS(val_ptr);
28241         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
28242         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
28243         Init_set_remote_network_address(&this_ptr_conv, val_conv);
28244 }
28245
28246 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
28247         LDKInitFeatures features_arg_conv;
28248         features_arg_conv.inner = (void*)(features_arg & (~1));
28249         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28250         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28251         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28252         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
28253         CHECK_ACCESS(remote_network_address_arg_ptr);
28254         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
28255         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
28256         uint32_t ret_ref = 0;
28257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28260         ret_ref = (uintptr_t)ret_var.inner;
28261         if (ret_var.is_owned) {
28262                 ret_ref |= 1;
28263         }
28264         return ret_ref;
28265 }
28266
28267 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
28268         LDKInit ret_var = Init_clone(arg);
28269 uint32_t ret_ref = 0;
28270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28273 ret_ref = (uintptr_t)ret_var.inner;
28274 if (ret_var.is_owned) {
28275         ret_ref |= 1;
28276 }
28277         return ret_ref;
28278 }
28279 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
28280         LDKInit arg_conv;
28281         arg_conv.inner = (void*)(arg & (~1));
28282         arg_conv.is_owned = false;
28283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28284         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
28285         return ret_conv;
28286 }
28287
28288 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
28289         LDKInit orig_conv;
28290         orig_conv.inner = (void*)(orig & (~1));
28291         orig_conv.is_owned = false;
28292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28293         LDKInit ret_var = Init_clone(&orig_conv);
28294         uint32_t ret_ref = 0;
28295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28298         ret_ref = (uintptr_t)ret_var.inner;
28299         if (ret_var.is_owned) {
28300                 ret_ref |= 1;
28301         }
28302         return ret_ref;
28303 }
28304
28305 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
28306         LDKErrorMessage this_obj_conv;
28307         this_obj_conv.inner = (void*)(this_obj & (~1));
28308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28310         ErrorMessage_free(this_obj_conv);
28311 }
28312
28313 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
28314         LDKErrorMessage this_ptr_conv;
28315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28316         this_ptr_conv.is_owned = false;
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28318         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28319         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
28320         return ret_arr;
28321 }
28322
28323 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28324         LDKErrorMessage this_ptr_conv;
28325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28326         this_ptr_conv.is_owned = false;
28327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28328         LDKThirtyTwoBytes val_ref;
28329         CHECK(val->arr_len == 32);
28330         memcpy(val_ref.data, val->elems, 32); FREE(val);
28331         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
28332 }
28333
28334 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
28335         LDKErrorMessage this_ptr_conv;
28336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28337         this_ptr_conv.is_owned = false;
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28339         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
28340         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28341         Str_free(ret_str);
28342         return ret_conv;
28343 }
28344
28345 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
28346         LDKErrorMessage this_ptr_conv;
28347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28348         this_ptr_conv.is_owned = false;
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28350         LDKStr val_conv = str_ref_to_owned_c(val);
28351         ErrorMessage_set_data(&this_ptr_conv, val_conv);
28352 }
28353
28354 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28355         LDKThirtyTwoBytes channel_id_arg_ref;
28356         CHECK(channel_id_arg->arr_len == 32);
28357         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28358         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28359         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
28360         uint32_t ret_ref = 0;
28361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28364         ret_ref = (uintptr_t)ret_var.inner;
28365         if (ret_var.is_owned) {
28366                 ret_ref |= 1;
28367         }
28368         return ret_ref;
28369 }
28370
28371 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
28372         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
28373 uint32_t ret_ref = 0;
28374 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28375 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28376 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28377 ret_ref = (uintptr_t)ret_var.inner;
28378 if (ret_var.is_owned) {
28379         ret_ref |= 1;
28380 }
28381         return ret_ref;
28382 }
28383 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
28384         LDKErrorMessage arg_conv;
28385         arg_conv.inner = (void*)(arg & (~1));
28386         arg_conv.is_owned = false;
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28388         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
28389         return ret_conv;
28390 }
28391
28392 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
28393         LDKErrorMessage orig_conv;
28394         orig_conv.inner = (void*)(orig & (~1));
28395         orig_conv.is_owned = false;
28396         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28397         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
28398         uint32_t ret_ref = 0;
28399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28402         ret_ref = (uintptr_t)ret_var.inner;
28403         if (ret_var.is_owned) {
28404                 ret_ref |= 1;
28405         }
28406         return ret_ref;
28407 }
28408
28409 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
28410         LDKWarningMessage this_obj_conv;
28411         this_obj_conv.inner = (void*)(this_obj & (~1));
28412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28414         WarningMessage_free(this_obj_conv);
28415 }
28416
28417 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
28418         LDKWarningMessage this_ptr_conv;
28419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28420         this_ptr_conv.is_owned = false;
28421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28422         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28423         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
28424         return ret_arr;
28425 }
28426
28427 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28428         LDKWarningMessage this_ptr_conv;
28429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28430         this_ptr_conv.is_owned = false;
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28432         LDKThirtyTwoBytes val_ref;
28433         CHECK(val->arr_len == 32);
28434         memcpy(val_ref.data, val->elems, 32); FREE(val);
28435         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
28436 }
28437
28438 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
28439         LDKWarningMessage this_ptr_conv;
28440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28441         this_ptr_conv.is_owned = false;
28442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28443         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
28444         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28445         Str_free(ret_str);
28446         return ret_conv;
28447 }
28448
28449 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
28450         LDKWarningMessage this_ptr_conv;
28451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28452         this_ptr_conv.is_owned = false;
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28454         LDKStr val_conv = str_ref_to_owned_c(val);
28455         WarningMessage_set_data(&this_ptr_conv, val_conv);
28456 }
28457
28458 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28459         LDKThirtyTwoBytes channel_id_arg_ref;
28460         CHECK(channel_id_arg->arr_len == 32);
28461         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28462         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28463         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
28464         uint32_t ret_ref = 0;
28465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28468         ret_ref = (uintptr_t)ret_var.inner;
28469         if (ret_var.is_owned) {
28470                 ret_ref |= 1;
28471         }
28472         return ret_ref;
28473 }
28474
28475 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
28476         LDKWarningMessage ret_var = WarningMessage_clone(arg);
28477 uint32_t ret_ref = 0;
28478 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28479 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28480 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28481 ret_ref = (uintptr_t)ret_var.inner;
28482 if (ret_var.is_owned) {
28483         ret_ref |= 1;
28484 }
28485         return ret_ref;
28486 }
28487 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
28488         LDKWarningMessage arg_conv;
28489         arg_conv.inner = (void*)(arg & (~1));
28490         arg_conv.is_owned = false;
28491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28492         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
28493         return ret_conv;
28494 }
28495
28496 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
28497         LDKWarningMessage orig_conv;
28498         orig_conv.inner = (void*)(orig & (~1));
28499         orig_conv.is_owned = false;
28500         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28501         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
28502         uint32_t ret_ref = 0;
28503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28506         ret_ref = (uintptr_t)ret_var.inner;
28507         if (ret_var.is_owned) {
28508                 ret_ref |= 1;
28509         }
28510         return ret_ref;
28511 }
28512
28513 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
28514         LDKPing this_obj_conv;
28515         this_obj_conv.inner = (void*)(this_obj & (~1));
28516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28518         Ping_free(this_obj_conv);
28519 }
28520
28521 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
28522         LDKPing this_ptr_conv;
28523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28524         this_ptr_conv.is_owned = false;
28525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28526         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
28527         return ret_conv;
28528 }
28529
28530 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
28531         LDKPing this_ptr_conv;
28532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28533         this_ptr_conv.is_owned = false;
28534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28535         Ping_set_ponglen(&this_ptr_conv, val);
28536 }
28537
28538 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
28539         LDKPing this_ptr_conv;
28540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28541         this_ptr_conv.is_owned = false;
28542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28543         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
28544         return ret_conv;
28545 }
28546
28547 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
28548         LDKPing this_ptr_conv;
28549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28550         this_ptr_conv.is_owned = false;
28551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28552         Ping_set_byteslen(&this_ptr_conv, val);
28553 }
28554
28555 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
28556         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
28557         uint32_t ret_ref = 0;
28558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28561         ret_ref = (uintptr_t)ret_var.inner;
28562         if (ret_var.is_owned) {
28563                 ret_ref |= 1;
28564         }
28565         return ret_ref;
28566 }
28567
28568 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
28569         LDKPing ret_var = Ping_clone(arg);
28570 uint32_t ret_ref = 0;
28571 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28572 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28573 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28574 ret_ref = (uintptr_t)ret_var.inner;
28575 if (ret_var.is_owned) {
28576         ret_ref |= 1;
28577 }
28578         return ret_ref;
28579 }
28580 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
28581         LDKPing arg_conv;
28582         arg_conv.inner = (void*)(arg & (~1));
28583         arg_conv.is_owned = false;
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28585         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
28586         return ret_conv;
28587 }
28588
28589 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
28590         LDKPing orig_conv;
28591         orig_conv.inner = (void*)(orig & (~1));
28592         orig_conv.is_owned = false;
28593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28594         LDKPing ret_var = Ping_clone(&orig_conv);
28595         uint32_t ret_ref = 0;
28596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28599         ret_ref = (uintptr_t)ret_var.inner;
28600         if (ret_var.is_owned) {
28601                 ret_ref |= 1;
28602         }
28603         return ret_ref;
28604 }
28605
28606 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
28607         LDKPong this_obj_conv;
28608         this_obj_conv.inner = (void*)(this_obj & (~1));
28609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28611         Pong_free(this_obj_conv);
28612 }
28613
28614 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
28615         LDKPong this_ptr_conv;
28616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28617         this_ptr_conv.is_owned = false;
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28619         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
28620         return ret_conv;
28621 }
28622
28623 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
28624         LDKPong this_ptr_conv;
28625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28626         this_ptr_conv.is_owned = false;
28627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28628         Pong_set_byteslen(&this_ptr_conv, val);
28629 }
28630
28631 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
28632         LDKPong ret_var = Pong_new(byteslen_arg);
28633         uint32_t ret_ref = 0;
28634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28637         ret_ref = (uintptr_t)ret_var.inner;
28638         if (ret_var.is_owned) {
28639                 ret_ref |= 1;
28640         }
28641         return ret_ref;
28642 }
28643
28644 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
28645         LDKPong ret_var = Pong_clone(arg);
28646 uint32_t ret_ref = 0;
28647 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28648 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28649 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28650 ret_ref = (uintptr_t)ret_var.inner;
28651 if (ret_var.is_owned) {
28652         ret_ref |= 1;
28653 }
28654         return ret_ref;
28655 }
28656 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
28657         LDKPong arg_conv;
28658         arg_conv.inner = (void*)(arg & (~1));
28659         arg_conv.is_owned = false;
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28661         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
28662         return ret_conv;
28663 }
28664
28665 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
28666         LDKPong orig_conv;
28667         orig_conv.inner = (void*)(orig & (~1));
28668         orig_conv.is_owned = false;
28669         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28670         LDKPong ret_var = Pong_clone(&orig_conv);
28671         uint32_t ret_ref = 0;
28672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28675         ret_ref = (uintptr_t)ret_var.inner;
28676         if (ret_var.is_owned) {
28677                 ret_ref |= 1;
28678         }
28679         return ret_ref;
28680 }
28681
28682 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
28683         LDKOpenChannel this_obj_conv;
28684         this_obj_conv.inner = (void*)(this_obj & (~1));
28685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28687         OpenChannel_free(this_obj_conv);
28688 }
28689
28690 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
28691         LDKOpenChannel this_ptr_conv;
28692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28693         this_ptr_conv.is_owned = false;
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28695         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28696         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28697         return ret_arr;
28698 }
28699
28700 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
28701         LDKOpenChannel this_ptr_conv;
28702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28703         this_ptr_conv.is_owned = false;
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28705         LDKThirtyTwoBytes val_ref;
28706         CHECK(val->arr_len == 32);
28707         memcpy(val_ref.data, val->elems, 32); FREE(val);
28708         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28709 }
28710
28711 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
28712         LDKOpenChannel this_ptr_conv;
28713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28714         this_ptr_conv.is_owned = false;
28715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28716         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28717         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28718         return ret_arr;
28719 }
28720
28721 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28722         LDKOpenChannel this_ptr_conv;
28723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28724         this_ptr_conv.is_owned = false;
28725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28726         LDKThirtyTwoBytes val_ref;
28727         CHECK(val->arr_len == 32);
28728         memcpy(val_ref.data, val->elems, 32); FREE(val);
28729         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28730 }
28731
28732 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
28733         LDKOpenChannel this_ptr_conv;
28734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28735         this_ptr_conv.is_owned = false;
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28737         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28738         return ret_conv;
28739 }
28740
28741 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
28742         LDKOpenChannel this_ptr_conv;
28743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28744         this_ptr_conv.is_owned = false;
28745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28746         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28747 }
28748
28749 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
28750         LDKOpenChannel this_ptr_conv;
28751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28752         this_ptr_conv.is_owned = false;
28753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28754         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28755         return ret_conv;
28756 }
28757
28758 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
28759         LDKOpenChannel this_ptr_conv;
28760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28761         this_ptr_conv.is_owned = false;
28762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28763         OpenChannel_set_push_msat(&this_ptr_conv, val);
28764 }
28765
28766 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28767         LDKOpenChannel this_ptr_conv;
28768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28769         this_ptr_conv.is_owned = false;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28771         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28772         return ret_conv;
28773 }
28774
28775 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28776         LDKOpenChannel this_ptr_conv;
28777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28778         this_ptr_conv.is_owned = false;
28779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28780         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28781 }
28782
28783 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) {
28784         LDKOpenChannel this_ptr_conv;
28785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28786         this_ptr_conv.is_owned = false;
28787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28788         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28789         return ret_conv;
28790 }
28791
28792 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) {
28793         LDKOpenChannel this_ptr_conv;
28794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28795         this_ptr_conv.is_owned = false;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28797         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28798 }
28799
28800 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28801         LDKOpenChannel this_ptr_conv;
28802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28803         this_ptr_conv.is_owned = false;
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28805         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28806         return ret_conv;
28807 }
28808
28809 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28810         LDKOpenChannel this_ptr_conv;
28811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28812         this_ptr_conv.is_owned = false;
28813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28814         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28815 }
28816
28817 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28818         LDKOpenChannel this_ptr_conv;
28819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28820         this_ptr_conv.is_owned = false;
28821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28822         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28823         return ret_conv;
28824 }
28825
28826 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28827         LDKOpenChannel this_ptr_conv;
28828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28829         this_ptr_conv.is_owned = false;
28830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28831         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28832 }
28833
28834 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
28835         LDKOpenChannel this_ptr_conv;
28836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28837         this_ptr_conv.is_owned = false;
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28839         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28840         return ret_conv;
28841 }
28842
28843 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28844         LDKOpenChannel this_ptr_conv;
28845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28846         this_ptr_conv.is_owned = false;
28847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28848         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28849 }
28850
28851 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
28852         LDKOpenChannel this_ptr_conv;
28853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28854         this_ptr_conv.is_owned = false;
28855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28856         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28857         return ret_conv;
28858 }
28859
28860 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28861         LDKOpenChannel this_ptr_conv;
28862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28863         this_ptr_conv.is_owned = false;
28864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28865         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28866 }
28867
28868 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28869         LDKOpenChannel this_ptr_conv;
28870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28871         this_ptr_conv.is_owned = false;
28872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28873         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28874         return ret_conv;
28875 }
28876
28877 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28878         LDKOpenChannel this_ptr_conv;
28879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28880         this_ptr_conv.is_owned = false;
28881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28882         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28883 }
28884
28885 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
28886         LDKOpenChannel this_ptr_conv;
28887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28888         this_ptr_conv.is_owned = false;
28889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28890         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28891         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28892         return ret_arr;
28893 }
28894
28895 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28896         LDKOpenChannel this_ptr_conv;
28897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28898         this_ptr_conv.is_owned = false;
28899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28900         LDKPublicKey val_ref;
28901         CHECK(val->arr_len == 33);
28902         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28903         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28904 }
28905
28906 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
28907         LDKOpenChannel this_ptr_conv;
28908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28909         this_ptr_conv.is_owned = false;
28910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28911         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28912         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28913         return ret_arr;
28914 }
28915
28916 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28917         LDKOpenChannel this_ptr_conv;
28918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28919         this_ptr_conv.is_owned = false;
28920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28921         LDKPublicKey val_ref;
28922         CHECK(val->arr_len == 33);
28923         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28924         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28925 }
28926
28927 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
28928         LDKOpenChannel this_ptr_conv;
28929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28930         this_ptr_conv.is_owned = false;
28931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28932         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28933         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28934         return ret_arr;
28935 }
28936
28937 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28938         LDKOpenChannel this_ptr_conv;
28939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28940         this_ptr_conv.is_owned = false;
28941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28942         LDKPublicKey val_ref;
28943         CHECK(val->arr_len == 33);
28944         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28945         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28946 }
28947
28948 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28949         LDKOpenChannel this_ptr_conv;
28950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28951         this_ptr_conv.is_owned = false;
28952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28953         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28954         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28955         return ret_arr;
28956 }
28957
28958 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28959         LDKOpenChannel this_ptr_conv;
28960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28961         this_ptr_conv.is_owned = false;
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28963         LDKPublicKey val_ref;
28964         CHECK(val->arr_len == 33);
28965         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28966         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28967 }
28968
28969 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
28970         LDKOpenChannel this_ptr_conv;
28971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28972         this_ptr_conv.is_owned = false;
28973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28974         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28975         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28976         return ret_arr;
28977 }
28978
28979 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28980         LDKOpenChannel this_ptr_conv;
28981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28982         this_ptr_conv.is_owned = false;
28983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28984         LDKPublicKey val_ref;
28985         CHECK(val->arr_len == 33);
28986         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28987         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28988 }
28989
28990 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28991         LDKOpenChannel this_ptr_conv;
28992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28993         this_ptr_conv.is_owned = false;
28994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28995         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28996         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28997         return ret_arr;
28998 }
28999
29000 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) {
29001         LDKOpenChannel this_ptr_conv;
29002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29003         this_ptr_conv.is_owned = false;
29004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29005         LDKPublicKey val_ref;
29006         CHECK(val->arr_len == 33);
29007         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29008         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29009 }
29010
29011 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
29012         LDKOpenChannel this_ptr_conv;
29013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29014         this_ptr_conv.is_owned = false;
29015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29016         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
29017         return ret_conv;
29018 }
29019
29020 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
29021         LDKOpenChannel this_ptr_conv;
29022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29023         this_ptr_conv.is_owned = false;
29024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29025         OpenChannel_set_channel_flags(&this_ptr_conv, val);
29026 }
29027
29028 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
29029         LDKOpenChannel this_ptr_conv;
29030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29031         this_ptr_conv.is_owned = false;
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29033         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
29034         uint32_t ret_ref = 0;
29035         if ((uintptr_t)ret_var.inner > 4096) {
29036                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29037                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29039                 ret_ref = (uintptr_t)ret_var.inner;
29040                 if (ret_var.is_owned) {
29041                         ret_ref |= 1;
29042                 }
29043         }
29044         return ret_ref;
29045 }
29046
29047 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29048         LDKOpenChannel this_ptr_conv;
29049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29050         this_ptr_conv.is_owned = false;
29051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29052         LDKChannelTypeFeatures val_conv;
29053         val_conv.inner = (void*)(val & (~1));
29054         val_conv.is_owned = (val & 1) || (val == 0);
29055         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29056         val_conv = ChannelTypeFeatures_clone(&val_conv);
29057         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
29058 }
29059
29060 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
29061         LDKOpenChannel ret_var = OpenChannel_clone(arg);
29062 uint32_t ret_ref = 0;
29063 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29064 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29065 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29066 ret_ref = (uintptr_t)ret_var.inner;
29067 if (ret_var.is_owned) {
29068         ret_ref |= 1;
29069 }
29070         return ret_ref;
29071 }
29072 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
29073         LDKOpenChannel arg_conv;
29074         arg_conv.inner = (void*)(arg & (~1));
29075         arg_conv.is_owned = false;
29076         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29077         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
29078         return ret_conv;
29079 }
29080
29081 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
29082         LDKOpenChannel orig_conv;
29083         orig_conv.inner = (void*)(orig & (~1));
29084         orig_conv.is_owned = false;
29085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29086         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
29087         uint32_t ret_ref = 0;
29088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29091         ret_ref = (uintptr_t)ret_var.inner;
29092         if (ret_var.is_owned) {
29093                 ret_ref |= 1;
29094         }
29095         return ret_ref;
29096 }
29097
29098 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
29099         LDKAcceptChannel this_obj_conv;
29100         this_obj_conv.inner = (void*)(this_obj & (~1));
29101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29103         AcceptChannel_free(this_obj_conv);
29104 }
29105
29106 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
29107         LDKAcceptChannel this_ptr_conv;
29108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29109         this_ptr_conv.is_owned = false;
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29111         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29112         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
29113         return ret_arr;
29114 }
29115
29116 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29117         LDKAcceptChannel this_ptr_conv;
29118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29119         this_ptr_conv.is_owned = false;
29120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29121         LDKThirtyTwoBytes val_ref;
29122         CHECK(val->arr_len == 32);
29123         memcpy(val_ref.data, val->elems, 32); FREE(val);
29124         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29125 }
29126
29127 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
29128         LDKAcceptChannel this_ptr_conv;
29129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29130         this_ptr_conv.is_owned = false;
29131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29132         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
29133         return ret_conv;
29134 }
29135
29136 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
29137         LDKAcceptChannel this_ptr_conv;
29138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29139         this_ptr_conv.is_owned = false;
29140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29141         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29142 }
29143
29144 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) {
29145         LDKAcceptChannel this_ptr_conv;
29146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29147         this_ptr_conv.is_owned = false;
29148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29149         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29150         return ret_conv;
29151 }
29152
29153 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) {
29154         LDKAcceptChannel this_ptr_conv;
29155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29156         this_ptr_conv.is_owned = false;
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29158         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
29159 }
29160
29161 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
29162         LDKAcceptChannel this_ptr_conv;
29163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29164         this_ptr_conv.is_owned = false;
29165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29166         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
29167         return ret_conv;
29168 }
29169
29170 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
29171         LDKAcceptChannel this_ptr_conv;
29172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29173         this_ptr_conv.is_owned = false;
29174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29175         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
29176 }
29177
29178 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
29179         LDKAcceptChannel this_ptr_conv;
29180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29181         this_ptr_conv.is_owned = false;
29182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29183         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
29184         return ret_conv;
29185 }
29186
29187 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29188         LDKAcceptChannel this_ptr_conv;
29189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29190         this_ptr_conv.is_owned = false;
29191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29192         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
29193 }
29194
29195 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
29196         LDKAcceptChannel this_ptr_conv;
29197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29198         this_ptr_conv.is_owned = false;
29199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29200         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
29201         return ret_conv;
29202 }
29203
29204 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
29205         LDKAcceptChannel this_ptr_conv;
29206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29207         this_ptr_conv.is_owned = false;
29208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29209         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
29210 }
29211
29212 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
29213         LDKAcceptChannel this_ptr_conv;
29214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29215         this_ptr_conv.is_owned = false;
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29217         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
29218         return ret_conv;
29219 }
29220
29221 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
29222         LDKAcceptChannel this_ptr_conv;
29223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29224         this_ptr_conv.is_owned = false;
29225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29226         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
29227 }
29228
29229 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
29230         LDKAcceptChannel this_ptr_conv;
29231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29232         this_ptr_conv.is_owned = false;
29233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29234         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
29235         return ret_conv;
29236 }
29237
29238 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
29239         LDKAcceptChannel 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         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
29244 }
29245
29246 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
29247         LDKAcceptChannel this_ptr_conv;
29248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29249         this_ptr_conv.is_owned = false;
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29251         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29252         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29253         return ret_arr;
29254 }
29255
29256 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29257         LDKAcceptChannel this_ptr_conv;
29258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29259         this_ptr_conv.is_owned = false;
29260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29261         LDKPublicKey val_ref;
29262         CHECK(val->arr_len == 33);
29263         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29264         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
29265 }
29266
29267 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
29268         LDKAcceptChannel this_ptr_conv;
29269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29270         this_ptr_conv.is_owned = false;
29271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29272         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29273         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29274         return ret_arr;
29275 }
29276
29277 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29278         LDKAcceptChannel this_ptr_conv;
29279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29280         this_ptr_conv.is_owned = false;
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29282         LDKPublicKey val_ref;
29283         CHECK(val->arr_len == 33);
29284         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29285         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
29286 }
29287
29288 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
29289         LDKAcceptChannel this_ptr_conv;
29290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29291         this_ptr_conv.is_owned = false;
29292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29293         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29294         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
29295         return ret_arr;
29296 }
29297
29298 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29299         LDKAcceptChannel this_ptr_conv;
29300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29301         this_ptr_conv.is_owned = false;
29302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29303         LDKPublicKey val_ref;
29304         CHECK(val->arr_len == 33);
29305         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29306         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
29307 }
29308
29309 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
29310         LDKAcceptChannel this_ptr_conv;
29311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29312         this_ptr_conv.is_owned = false;
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29315         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29316         return ret_arr;
29317 }
29318
29319 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29320         LDKAcceptChannel this_ptr_conv;
29321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29322         this_ptr_conv.is_owned = false;
29323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29324         LDKPublicKey val_ref;
29325         CHECK(val->arr_len == 33);
29326         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29327         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29328 }
29329
29330 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
29331         LDKAcceptChannel this_ptr_conv;
29332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29333         this_ptr_conv.is_owned = false;
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29335         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29336         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29337         return ret_arr;
29338 }
29339
29340 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29341         LDKAcceptChannel this_ptr_conv;
29342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29343         this_ptr_conv.is_owned = false;
29344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29345         LDKPublicKey val_ref;
29346         CHECK(val->arr_len == 33);
29347         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29348         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29349 }
29350
29351 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
29352         LDKAcceptChannel this_ptr_conv;
29353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29354         this_ptr_conv.is_owned = false;
29355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29356         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29357         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29358         return ret_arr;
29359 }
29360
29361 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) {
29362         LDKAcceptChannel this_ptr_conv;
29363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29364         this_ptr_conv.is_owned = false;
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29366         LDKPublicKey val_ref;
29367         CHECK(val->arr_len == 33);
29368         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29369         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29370 }
29371
29372 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
29373         LDKAcceptChannel this_ptr_conv;
29374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29375         this_ptr_conv.is_owned = false;
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29377         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
29378         uint32_t ret_ref = 0;
29379         if ((uintptr_t)ret_var.inner > 4096) {
29380                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29381                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29383                 ret_ref = (uintptr_t)ret_var.inner;
29384                 if (ret_var.is_owned) {
29385                         ret_ref |= 1;
29386                 }
29387         }
29388         return ret_ref;
29389 }
29390
29391 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29392         LDKAcceptChannel this_ptr_conv;
29393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29394         this_ptr_conv.is_owned = false;
29395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29396         LDKChannelTypeFeatures val_conv;
29397         val_conv.inner = (void*)(val & (~1));
29398         val_conv.is_owned = (val & 1) || (val == 0);
29399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29400         val_conv = ChannelTypeFeatures_clone(&val_conv);
29401         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
29402 }
29403
29404 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
29405         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
29406 uint32_t ret_ref = 0;
29407 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29408 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29409 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29410 ret_ref = (uintptr_t)ret_var.inner;
29411 if (ret_var.is_owned) {
29412         ret_ref |= 1;
29413 }
29414         return ret_ref;
29415 }
29416 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
29417         LDKAcceptChannel arg_conv;
29418         arg_conv.inner = (void*)(arg & (~1));
29419         arg_conv.is_owned = false;
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29421         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
29422         return ret_conv;
29423 }
29424
29425 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
29426         LDKAcceptChannel orig_conv;
29427         orig_conv.inner = (void*)(orig & (~1));
29428         orig_conv.is_owned = false;
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29430         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
29431         uint32_t ret_ref = 0;
29432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29435         ret_ref = (uintptr_t)ret_var.inner;
29436         if (ret_var.is_owned) {
29437                 ret_ref |= 1;
29438         }
29439         return ret_ref;
29440 }
29441
29442 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
29443         LDKFundingCreated this_obj_conv;
29444         this_obj_conv.inner = (void*)(this_obj & (~1));
29445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29447         FundingCreated_free(this_obj_conv);
29448 }
29449
29450 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
29451         LDKFundingCreated this_ptr_conv;
29452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29453         this_ptr_conv.is_owned = false;
29454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29455         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29456         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
29457         return ret_arr;
29458 }
29459
29460 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29461         LDKFundingCreated this_ptr_conv;
29462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29463         this_ptr_conv.is_owned = false;
29464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29465         LDKThirtyTwoBytes val_ref;
29466         CHECK(val->arr_len == 32);
29467         memcpy(val_ref.data, val->elems, 32); FREE(val);
29468         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
29469 }
29470
29471 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
29472         LDKFundingCreated this_ptr_conv;
29473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29474         this_ptr_conv.is_owned = false;
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29476         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29477         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
29478         return ret_arr;
29479 }
29480
29481 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
29482         LDKFundingCreated this_ptr_conv;
29483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29484         this_ptr_conv.is_owned = false;
29485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29486         LDKThirtyTwoBytes val_ref;
29487         CHECK(val->arr_len == 32);
29488         memcpy(val_ref.data, val->elems, 32); FREE(val);
29489         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
29490 }
29491
29492 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
29493         LDKFundingCreated this_ptr_conv;
29494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29495         this_ptr_conv.is_owned = false;
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29497         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
29498         return ret_conv;
29499 }
29500
29501 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
29502         LDKFundingCreated this_ptr_conv;
29503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29504         this_ptr_conv.is_owned = false;
29505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29506         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
29507 }
29508
29509 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
29510         LDKFundingCreated this_ptr_conv;
29511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29512         this_ptr_conv.is_owned = false;
29513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29514         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29515         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
29516         return ret_arr;
29517 }
29518
29519 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
29520         LDKFundingCreated this_ptr_conv;
29521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29522         this_ptr_conv.is_owned = false;
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29524         LDKSignature val_ref;
29525         CHECK(val->arr_len == 64);
29526         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29527         FundingCreated_set_signature(&this_ptr_conv, val_ref);
29528 }
29529
29530 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) {
29531         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
29532         CHECK(temporary_channel_id_arg->arr_len == 32);
29533         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
29534         LDKThirtyTwoBytes funding_txid_arg_ref;
29535         CHECK(funding_txid_arg->arr_len == 32);
29536         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
29537         LDKSignature signature_arg_ref;
29538         CHECK(signature_arg->arr_len == 64);
29539         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29540         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
29541         uint32_t ret_ref = 0;
29542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29545         ret_ref = (uintptr_t)ret_var.inner;
29546         if (ret_var.is_owned) {
29547                 ret_ref |= 1;
29548         }
29549         return ret_ref;
29550 }
29551
29552 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
29553         LDKFundingCreated ret_var = FundingCreated_clone(arg);
29554 uint32_t ret_ref = 0;
29555 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29556 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29557 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29558 ret_ref = (uintptr_t)ret_var.inner;
29559 if (ret_var.is_owned) {
29560         ret_ref |= 1;
29561 }
29562         return ret_ref;
29563 }
29564 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
29565         LDKFundingCreated arg_conv;
29566         arg_conv.inner = (void*)(arg & (~1));
29567         arg_conv.is_owned = false;
29568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29569         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
29570         return ret_conv;
29571 }
29572
29573 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
29574         LDKFundingCreated orig_conv;
29575         orig_conv.inner = (void*)(orig & (~1));
29576         orig_conv.is_owned = false;
29577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29578         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
29579         uint32_t ret_ref = 0;
29580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29583         ret_ref = (uintptr_t)ret_var.inner;
29584         if (ret_var.is_owned) {
29585                 ret_ref |= 1;
29586         }
29587         return ret_ref;
29588 }
29589
29590 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
29591         LDKFundingSigned this_obj_conv;
29592         this_obj_conv.inner = (void*)(this_obj & (~1));
29593         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29595         FundingSigned_free(this_obj_conv);
29596 }
29597
29598 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
29599         LDKFundingSigned this_ptr_conv;
29600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29601         this_ptr_conv.is_owned = false;
29602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29603         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29604         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
29605         return ret_arr;
29606 }
29607
29608 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29609         LDKFundingSigned this_ptr_conv;
29610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29611         this_ptr_conv.is_owned = false;
29612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29613         LDKThirtyTwoBytes val_ref;
29614         CHECK(val->arr_len == 32);
29615         memcpy(val_ref.data, val->elems, 32); FREE(val);
29616         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
29617 }
29618
29619 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
29620         LDKFundingSigned this_ptr_conv;
29621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29622         this_ptr_conv.is_owned = false;
29623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29624         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29625         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29626         return ret_arr;
29627 }
29628
29629 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29630         LDKFundingSigned 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         LDKSignature val_ref;
29635         CHECK(val->arr_len == 64);
29636         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29637         FundingSigned_set_signature(&this_ptr_conv, val_ref);
29638 }
29639
29640 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
29641         LDKThirtyTwoBytes channel_id_arg_ref;
29642         CHECK(channel_id_arg->arr_len == 32);
29643         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29644         LDKSignature signature_arg_ref;
29645         CHECK(signature_arg->arr_len == 64);
29646         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29647         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29648         uint32_t ret_ref = 0;
29649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29652         ret_ref = (uintptr_t)ret_var.inner;
29653         if (ret_var.is_owned) {
29654                 ret_ref |= 1;
29655         }
29656         return ret_ref;
29657 }
29658
29659 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29660         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29661 uint32_t ret_ref = 0;
29662 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29663 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29664 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29665 ret_ref = (uintptr_t)ret_var.inner;
29666 if (ret_var.is_owned) {
29667         ret_ref |= 1;
29668 }
29669         return ret_ref;
29670 }
29671 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
29672         LDKFundingSigned arg_conv;
29673         arg_conv.inner = (void*)(arg & (~1));
29674         arg_conv.is_owned = false;
29675         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29676         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29677         return ret_conv;
29678 }
29679
29680 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
29681         LDKFundingSigned orig_conv;
29682         orig_conv.inner = (void*)(orig & (~1));
29683         orig_conv.is_owned = false;
29684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29685         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29686         uint32_t ret_ref = 0;
29687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29690         ret_ref = (uintptr_t)ret_var.inner;
29691         if (ret_var.is_owned) {
29692                 ret_ref |= 1;
29693         }
29694         return ret_ref;
29695 }
29696
29697 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
29698         LDKChannelReady this_obj_conv;
29699         this_obj_conv.inner = (void*)(this_obj & (~1));
29700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29702         ChannelReady_free(this_obj_conv);
29703 }
29704
29705 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
29706         LDKChannelReady this_ptr_conv;
29707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29708         this_ptr_conv.is_owned = false;
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29710         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29711         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29712         return ret_arr;
29713 }
29714
29715 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29716         LDKChannelReady this_ptr_conv;
29717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29718         this_ptr_conv.is_owned = false;
29719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29720         LDKThirtyTwoBytes val_ref;
29721         CHECK(val->arr_len == 32);
29722         memcpy(val_ref.data, val->elems, 32); FREE(val);
29723         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29724 }
29725
29726 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
29727         LDKChannelReady this_ptr_conv;
29728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29729         this_ptr_conv.is_owned = false;
29730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29731         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29732         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29733         return ret_arr;
29734 }
29735
29736 void  __attribute__((export_name("TS_ChannelReady_set_next_per_commitment_point"))) TS_ChannelReady_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
29737         LDKChannelReady this_ptr_conv;
29738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29739         this_ptr_conv.is_owned = false;
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29741         LDKPublicKey val_ref;
29742         CHECK(val->arr_len == 33);
29743         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29744         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29745 }
29746
29747 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
29748         LDKChannelReady this_ptr_conv;
29749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29750         this_ptr_conv.is_owned = false;
29751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29752         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29753         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29754         uint32_t ret_ref = (uintptr_t)ret_copy;
29755         return ret_ref;
29756 }
29757
29758 void  __attribute__((export_name("TS_ChannelReady_set_short_channel_id_alias"))) TS_ChannelReady_set_short_channel_id_alias(uint32_t this_ptr, uint32_t val) {
29759         LDKChannelReady this_ptr_conv;
29760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29761         this_ptr_conv.is_owned = false;
29762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29763         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29764         CHECK_ACCESS(val_ptr);
29765         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29766         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29767         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29768 }
29769
29770 uint32_t  __attribute__((export_name("TS_ChannelReady_new"))) TS_ChannelReady_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, uint32_t short_channel_id_alias_arg) {
29771         LDKThirtyTwoBytes channel_id_arg_ref;
29772         CHECK(channel_id_arg->arr_len == 32);
29773         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29774         LDKPublicKey next_per_commitment_point_arg_ref;
29775         CHECK(next_per_commitment_point_arg->arr_len == 33);
29776         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29777         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
29778         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29779         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29780         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
29781         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29782         uint32_t ret_ref = 0;
29783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29786         ret_ref = (uintptr_t)ret_var.inner;
29787         if (ret_var.is_owned) {
29788                 ret_ref |= 1;
29789         }
29790         return ret_ref;
29791 }
29792
29793 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29794         LDKChannelReady ret_var = ChannelReady_clone(arg);
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 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
29806         LDKChannelReady arg_conv;
29807         arg_conv.inner = (void*)(arg & (~1));
29808         arg_conv.is_owned = false;
29809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29810         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29811         return ret_conv;
29812 }
29813
29814 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
29815         LDKChannelReady orig_conv;
29816         orig_conv.inner = (void*)(orig & (~1));
29817         orig_conv.is_owned = false;
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29819         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29820         uint32_t ret_ref = 0;
29821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29824         ret_ref = (uintptr_t)ret_var.inner;
29825         if (ret_var.is_owned) {
29826                 ret_ref |= 1;
29827         }
29828         return ret_ref;
29829 }
29830
29831 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
29832         LDKShutdown this_obj_conv;
29833         this_obj_conv.inner = (void*)(this_obj & (~1));
29834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29836         Shutdown_free(this_obj_conv);
29837 }
29838
29839 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
29840         LDKShutdown this_ptr_conv;
29841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29842         this_ptr_conv.is_owned = false;
29843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29844         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29845         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29846         return ret_arr;
29847 }
29848
29849 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29850         LDKShutdown this_ptr_conv;
29851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29852         this_ptr_conv.is_owned = false;
29853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29854         LDKThirtyTwoBytes val_ref;
29855         CHECK(val->arr_len == 32);
29856         memcpy(val_ref.data, val->elems, 32); FREE(val);
29857         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29858 }
29859
29860 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
29861         LDKShutdown this_ptr_conv;
29862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29863         this_ptr_conv.is_owned = false;
29864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29865         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29866         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29867         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29868         return ret_arr;
29869 }
29870
29871 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
29872         LDKShutdown this_ptr_conv;
29873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29874         this_ptr_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29876         LDKCVec_u8Z val_ref;
29877         val_ref.datalen = val->arr_len;
29878         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29879         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29880         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29881 }
29882
29883 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29884         LDKThirtyTwoBytes channel_id_arg_ref;
29885         CHECK(channel_id_arg->arr_len == 32);
29886         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29887         LDKCVec_u8Z scriptpubkey_arg_ref;
29888         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29889         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29890         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29891         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29892         uint32_t ret_ref = 0;
29893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29896         ret_ref = (uintptr_t)ret_var.inner;
29897         if (ret_var.is_owned) {
29898                 ret_ref |= 1;
29899         }
29900         return ret_ref;
29901 }
29902
29903 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29904         LDKShutdown ret_var = Shutdown_clone(arg);
29905 uint32_t ret_ref = 0;
29906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29909 ret_ref = (uintptr_t)ret_var.inner;
29910 if (ret_var.is_owned) {
29911         ret_ref |= 1;
29912 }
29913         return ret_ref;
29914 }
29915 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
29916         LDKShutdown arg_conv;
29917         arg_conv.inner = (void*)(arg & (~1));
29918         arg_conv.is_owned = false;
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29920         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29921         return ret_conv;
29922 }
29923
29924 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
29925         LDKShutdown orig_conv;
29926         orig_conv.inner = (void*)(orig & (~1));
29927         orig_conv.is_owned = false;
29928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29929         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29930         uint32_t ret_ref = 0;
29931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29934         ret_ref = (uintptr_t)ret_var.inner;
29935         if (ret_var.is_owned) {
29936                 ret_ref |= 1;
29937         }
29938         return ret_ref;
29939 }
29940
29941 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
29942         LDKClosingSignedFeeRange this_obj_conv;
29943         this_obj_conv.inner = (void*)(this_obj & (~1));
29944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29946         ClosingSignedFeeRange_free(this_obj_conv);
29947 }
29948
29949 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
29950         LDKClosingSignedFeeRange this_ptr_conv;
29951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29952         this_ptr_conv.is_owned = false;
29953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29954         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29955         return ret_conv;
29956 }
29957
29958 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
29959         LDKClosingSignedFeeRange this_ptr_conv;
29960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29961         this_ptr_conv.is_owned = false;
29962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29963         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29964 }
29965
29966 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
29967         LDKClosingSignedFeeRange this_ptr_conv;
29968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29969         this_ptr_conv.is_owned = false;
29970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29971         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29972         return ret_conv;
29973 }
29974
29975 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
29976         LDKClosingSignedFeeRange this_ptr_conv;
29977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29978         this_ptr_conv.is_owned = false;
29979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29980         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
29981 }
29982
29983 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
29984         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
29985         uint32_t ret_ref = 0;
29986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29989         ret_ref = (uintptr_t)ret_var.inner;
29990         if (ret_var.is_owned) {
29991                 ret_ref |= 1;
29992         }
29993         return ret_ref;
29994 }
29995
29996 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
29997         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
29998 uint32_t ret_ref = 0;
29999 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30000 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30001 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30002 ret_ref = (uintptr_t)ret_var.inner;
30003 if (ret_var.is_owned) {
30004         ret_ref |= 1;
30005 }
30006         return ret_ref;
30007 }
30008 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
30009         LDKClosingSignedFeeRange arg_conv;
30010         arg_conv.inner = (void*)(arg & (~1));
30011         arg_conv.is_owned = false;
30012         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30013         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
30014         return ret_conv;
30015 }
30016
30017 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
30018         LDKClosingSignedFeeRange orig_conv;
30019         orig_conv.inner = (void*)(orig & (~1));
30020         orig_conv.is_owned = false;
30021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30022         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
30023         uint32_t ret_ref = 0;
30024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30027         ret_ref = (uintptr_t)ret_var.inner;
30028         if (ret_var.is_owned) {
30029                 ret_ref |= 1;
30030         }
30031         return ret_ref;
30032 }
30033
30034 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
30035         LDKClosingSigned this_obj_conv;
30036         this_obj_conv.inner = (void*)(this_obj & (~1));
30037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30039         ClosingSigned_free(this_obj_conv);
30040 }
30041
30042 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
30043         LDKClosingSigned this_ptr_conv;
30044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30045         this_ptr_conv.is_owned = false;
30046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30047         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30048         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
30049         return ret_arr;
30050 }
30051
30052 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30053         LDKClosingSigned this_ptr_conv;
30054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30055         this_ptr_conv.is_owned = false;
30056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30057         LDKThirtyTwoBytes val_ref;
30058         CHECK(val->arr_len == 32);
30059         memcpy(val_ref.data, val->elems, 32); FREE(val);
30060         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
30061 }
30062
30063 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
30064         LDKClosingSigned this_ptr_conv;
30065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30066         this_ptr_conv.is_owned = false;
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30068         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
30069         return ret_conv;
30070 }
30071
30072 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
30073         LDKClosingSigned this_ptr_conv;
30074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30075         this_ptr_conv.is_owned = false;
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30077         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
30078 }
30079
30080 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
30081         LDKClosingSigned this_ptr_conv;
30082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30083         this_ptr_conv.is_owned = false;
30084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30085         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30086         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
30087         return ret_arr;
30088 }
30089
30090 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30091         LDKClosingSigned this_ptr_conv;
30092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30093         this_ptr_conv.is_owned = false;
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30095         LDKSignature val_ref;
30096         CHECK(val->arr_len == 64);
30097         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30098         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
30099 }
30100
30101 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
30102         LDKClosingSigned this_ptr_conv;
30103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30104         this_ptr_conv.is_owned = false;
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30106         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
30107         uint32_t ret_ref = 0;
30108         if ((uintptr_t)ret_var.inner > 4096) {
30109                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30110                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30112                 ret_ref = (uintptr_t)ret_var.inner;
30113                 if (ret_var.is_owned) {
30114                         ret_ref |= 1;
30115                 }
30116         }
30117         return ret_ref;
30118 }
30119
30120 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
30121         LDKClosingSigned this_ptr_conv;
30122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30123         this_ptr_conv.is_owned = false;
30124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30125         LDKClosingSignedFeeRange val_conv;
30126         val_conv.inner = (void*)(val & (~1));
30127         val_conv.is_owned = (val & 1) || (val == 0);
30128         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30129         val_conv = ClosingSignedFeeRange_clone(&val_conv);
30130         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
30131 }
30132
30133 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) {
30134         LDKThirtyTwoBytes channel_id_arg_ref;
30135         CHECK(channel_id_arg->arr_len == 32);
30136         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30137         LDKSignature signature_arg_ref;
30138         CHECK(signature_arg->arr_len == 64);
30139         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30140         LDKClosingSignedFeeRange fee_range_arg_conv;
30141         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
30142         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
30143         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
30144         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
30145         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
30146         uint32_t ret_ref = 0;
30147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30150         ret_ref = (uintptr_t)ret_var.inner;
30151         if (ret_var.is_owned) {
30152                 ret_ref |= 1;
30153         }
30154         return ret_ref;
30155 }
30156
30157 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
30158         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
30159 uint32_t ret_ref = 0;
30160 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30161 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30162 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30163 ret_ref = (uintptr_t)ret_var.inner;
30164 if (ret_var.is_owned) {
30165         ret_ref |= 1;
30166 }
30167         return ret_ref;
30168 }
30169 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
30170         LDKClosingSigned arg_conv;
30171         arg_conv.inner = (void*)(arg & (~1));
30172         arg_conv.is_owned = false;
30173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30174         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
30175         return ret_conv;
30176 }
30177
30178 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
30179         LDKClosingSigned orig_conv;
30180         orig_conv.inner = (void*)(orig & (~1));
30181         orig_conv.is_owned = false;
30182         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30183         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
30184         uint32_t ret_ref = 0;
30185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30188         ret_ref = (uintptr_t)ret_var.inner;
30189         if (ret_var.is_owned) {
30190                 ret_ref |= 1;
30191         }
30192         return ret_ref;
30193 }
30194
30195 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
30196         LDKUpdateAddHTLC this_obj_conv;
30197         this_obj_conv.inner = (void*)(this_obj & (~1));
30198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30200         UpdateAddHTLC_free(this_obj_conv);
30201 }
30202
30203 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
30204         LDKUpdateAddHTLC this_ptr_conv;
30205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30206         this_ptr_conv.is_owned = false;
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30208         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30209         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
30210         return ret_arr;
30211 }
30212
30213 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30214         LDKUpdateAddHTLC this_ptr_conv;
30215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30216         this_ptr_conv.is_owned = false;
30217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30218         LDKThirtyTwoBytes val_ref;
30219         CHECK(val->arr_len == 32);
30220         memcpy(val_ref.data, val->elems, 32); FREE(val);
30221         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
30222 }
30223
30224 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
30225         LDKUpdateAddHTLC this_ptr_conv;
30226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30227         this_ptr_conv.is_owned = false;
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30229         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
30230         return ret_conv;
30231 }
30232
30233 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30234         LDKUpdateAddHTLC this_ptr_conv;
30235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30236         this_ptr_conv.is_owned = false;
30237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30238         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
30239 }
30240
30241 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
30242         LDKUpdateAddHTLC this_ptr_conv;
30243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30244         this_ptr_conv.is_owned = false;
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30246         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
30247         return ret_conv;
30248 }
30249
30250 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
30251         LDKUpdateAddHTLC this_ptr_conv;
30252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30253         this_ptr_conv.is_owned = false;
30254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30255         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
30256 }
30257
30258 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
30259         LDKUpdateAddHTLC this_ptr_conv;
30260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30261         this_ptr_conv.is_owned = false;
30262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30263         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30264         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
30265         return ret_arr;
30266 }
30267
30268 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
30269         LDKUpdateAddHTLC this_ptr_conv;
30270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30271         this_ptr_conv.is_owned = false;
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30273         LDKThirtyTwoBytes val_ref;
30274         CHECK(val->arr_len == 32);
30275         memcpy(val_ref.data, val->elems, 32); FREE(val);
30276         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
30277 }
30278
30279 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
30280         LDKUpdateAddHTLC this_ptr_conv;
30281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30282         this_ptr_conv.is_owned = false;
30283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30284         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
30285         return ret_conv;
30286 }
30287
30288 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
30289         LDKUpdateAddHTLC this_ptr_conv;
30290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30291         this_ptr_conv.is_owned = false;
30292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30293         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
30294 }
30295
30296 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
30297         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
30298 uint32_t ret_ref = 0;
30299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30302 ret_ref = (uintptr_t)ret_var.inner;
30303 if (ret_var.is_owned) {
30304         ret_ref |= 1;
30305 }
30306         return ret_ref;
30307 }
30308 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
30309         LDKUpdateAddHTLC arg_conv;
30310         arg_conv.inner = (void*)(arg & (~1));
30311         arg_conv.is_owned = false;
30312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30313         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
30314         return ret_conv;
30315 }
30316
30317 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
30318         LDKUpdateAddHTLC orig_conv;
30319         orig_conv.inner = (void*)(orig & (~1));
30320         orig_conv.is_owned = false;
30321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30322         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
30323         uint32_t ret_ref = 0;
30324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30327         ret_ref = (uintptr_t)ret_var.inner;
30328         if (ret_var.is_owned) {
30329                 ret_ref |= 1;
30330         }
30331         return ret_ref;
30332 }
30333
30334 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
30335         LDKUpdateFulfillHTLC this_obj_conv;
30336         this_obj_conv.inner = (void*)(this_obj & (~1));
30337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30339         UpdateFulfillHTLC_free(this_obj_conv);
30340 }
30341
30342 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
30343         LDKUpdateFulfillHTLC this_ptr_conv;
30344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30345         this_ptr_conv.is_owned = false;
30346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30347         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30348         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
30349         return ret_arr;
30350 }
30351
30352 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30353         LDKUpdateFulfillHTLC this_ptr_conv;
30354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30355         this_ptr_conv.is_owned = false;
30356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30357         LDKThirtyTwoBytes val_ref;
30358         CHECK(val->arr_len == 32);
30359         memcpy(val_ref.data, val->elems, 32); FREE(val);
30360         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
30361 }
30362
30363 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
30364         LDKUpdateFulfillHTLC this_ptr_conv;
30365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30366         this_ptr_conv.is_owned = false;
30367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30368         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
30369         return ret_conv;
30370 }
30371
30372 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30373         LDKUpdateFulfillHTLC this_ptr_conv;
30374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30375         this_ptr_conv.is_owned = false;
30376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30377         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
30378 }
30379
30380 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
30381         LDKUpdateFulfillHTLC this_ptr_conv;
30382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30383         this_ptr_conv.is_owned = false;
30384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30385         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30386         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
30387         return ret_arr;
30388 }
30389
30390 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
30391         LDKUpdateFulfillHTLC this_ptr_conv;
30392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30393         this_ptr_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30395         LDKThirtyTwoBytes val_ref;
30396         CHECK(val->arr_len == 32);
30397         memcpy(val_ref.data, val->elems, 32); FREE(val);
30398         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
30399 }
30400
30401 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) {
30402         LDKThirtyTwoBytes channel_id_arg_ref;
30403         CHECK(channel_id_arg->arr_len == 32);
30404         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30405         LDKThirtyTwoBytes payment_preimage_arg_ref;
30406         CHECK(payment_preimage_arg->arr_len == 32);
30407         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
30408         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
30409         uint32_t ret_ref = 0;
30410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30413         ret_ref = (uintptr_t)ret_var.inner;
30414         if (ret_var.is_owned) {
30415                 ret_ref |= 1;
30416         }
30417         return ret_ref;
30418 }
30419
30420 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
30421         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
30422 uint32_t ret_ref = 0;
30423 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30424 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30425 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30426 ret_ref = (uintptr_t)ret_var.inner;
30427 if (ret_var.is_owned) {
30428         ret_ref |= 1;
30429 }
30430         return ret_ref;
30431 }
30432 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
30433         LDKUpdateFulfillHTLC arg_conv;
30434         arg_conv.inner = (void*)(arg & (~1));
30435         arg_conv.is_owned = false;
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30437         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
30438         return ret_conv;
30439 }
30440
30441 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
30442         LDKUpdateFulfillHTLC orig_conv;
30443         orig_conv.inner = (void*)(orig & (~1));
30444         orig_conv.is_owned = false;
30445         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30446         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
30447         uint32_t ret_ref = 0;
30448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30451         ret_ref = (uintptr_t)ret_var.inner;
30452         if (ret_var.is_owned) {
30453                 ret_ref |= 1;
30454         }
30455         return ret_ref;
30456 }
30457
30458 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
30459         LDKUpdateFailHTLC this_obj_conv;
30460         this_obj_conv.inner = (void*)(this_obj & (~1));
30461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30463         UpdateFailHTLC_free(this_obj_conv);
30464 }
30465
30466 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
30467         LDKUpdateFailHTLC this_ptr_conv;
30468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30469         this_ptr_conv.is_owned = false;
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30471         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30472         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
30473         return ret_arr;
30474 }
30475
30476 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30477         LDKUpdateFailHTLC this_ptr_conv;
30478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30479         this_ptr_conv.is_owned = false;
30480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30481         LDKThirtyTwoBytes val_ref;
30482         CHECK(val->arr_len == 32);
30483         memcpy(val_ref.data, val->elems, 32); FREE(val);
30484         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
30485 }
30486
30487 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
30488         LDKUpdateFailHTLC this_ptr_conv;
30489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30490         this_ptr_conv.is_owned = false;
30491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30492         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
30493         return ret_conv;
30494 }
30495
30496 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30497         LDKUpdateFailHTLC this_ptr_conv;
30498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30499         this_ptr_conv.is_owned = false;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30501         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
30502 }
30503
30504 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
30505         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
30506 uint32_t ret_ref = 0;
30507 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30508 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30509 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30510 ret_ref = (uintptr_t)ret_var.inner;
30511 if (ret_var.is_owned) {
30512         ret_ref |= 1;
30513 }
30514         return ret_ref;
30515 }
30516 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
30517         LDKUpdateFailHTLC arg_conv;
30518         arg_conv.inner = (void*)(arg & (~1));
30519         arg_conv.is_owned = false;
30520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30521         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
30522         return ret_conv;
30523 }
30524
30525 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
30526         LDKUpdateFailHTLC orig_conv;
30527         orig_conv.inner = (void*)(orig & (~1));
30528         orig_conv.is_owned = false;
30529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30530         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
30531         uint32_t ret_ref = 0;
30532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30535         ret_ref = (uintptr_t)ret_var.inner;
30536         if (ret_var.is_owned) {
30537                 ret_ref |= 1;
30538         }
30539         return ret_ref;
30540 }
30541
30542 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
30543         LDKUpdateFailMalformedHTLC this_obj_conv;
30544         this_obj_conv.inner = (void*)(this_obj & (~1));
30545         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30547         UpdateFailMalformedHTLC_free(this_obj_conv);
30548 }
30549
30550 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
30551         LDKUpdateFailMalformedHTLC this_ptr_conv;
30552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30553         this_ptr_conv.is_owned = false;
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30555         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30556         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
30557         return ret_arr;
30558 }
30559
30560 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30561         LDKUpdateFailMalformedHTLC this_ptr_conv;
30562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30563         this_ptr_conv.is_owned = false;
30564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30565         LDKThirtyTwoBytes val_ref;
30566         CHECK(val->arr_len == 32);
30567         memcpy(val_ref.data, val->elems, 32); FREE(val);
30568         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
30569 }
30570
30571 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
30572         LDKUpdateFailMalformedHTLC 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         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
30577         return ret_conv;
30578 }
30579
30580 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30581         LDKUpdateFailMalformedHTLC this_ptr_conv;
30582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30583         this_ptr_conv.is_owned = false;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30585         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
30586 }
30587
30588 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
30589         LDKUpdateFailMalformedHTLC this_ptr_conv;
30590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30591         this_ptr_conv.is_owned = false;
30592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30593         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
30594         return ret_conv;
30595 }
30596
30597 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
30598         LDKUpdateFailMalformedHTLC this_ptr_conv;
30599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30600         this_ptr_conv.is_owned = false;
30601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30602         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
30603 }
30604
30605 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
30606         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
30607 uint32_t ret_ref = 0;
30608 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30609 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30610 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30611 ret_ref = (uintptr_t)ret_var.inner;
30612 if (ret_var.is_owned) {
30613         ret_ref |= 1;
30614 }
30615         return ret_ref;
30616 }
30617 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
30618         LDKUpdateFailMalformedHTLC arg_conv;
30619         arg_conv.inner = (void*)(arg & (~1));
30620         arg_conv.is_owned = false;
30621         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30622         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
30623         return ret_conv;
30624 }
30625
30626 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
30627         LDKUpdateFailMalformedHTLC orig_conv;
30628         orig_conv.inner = (void*)(orig & (~1));
30629         orig_conv.is_owned = false;
30630         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30631         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
30632         uint32_t ret_ref = 0;
30633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30636         ret_ref = (uintptr_t)ret_var.inner;
30637         if (ret_var.is_owned) {
30638                 ret_ref |= 1;
30639         }
30640         return ret_ref;
30641 }
30642
30643 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
30644         LDKCommitmentSigned this_obj_conv;
30645         this_obj_conv.inner = (void*)(this_obj & (~1));
30646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30648         CommitmentSigned_free(this_obj_conv);
30649 }
30650
30651 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
30652         LDKCommitmentSigned this_ptr_conv;
30653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30654         this_ptr_conv.is_owned = false;
30655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30656         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30657         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30658         return ret_arr;
30659 }
30660
30661 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30662         LDKCommitmentSigned this_ptr_conv;
30663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30664         this_ptr_conv.is_owned = false;
30665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30666         LDKThirtyTwoBytes val_ref;
30667         CHECK(val->arr_len == 32);
30668         memcpy(val_ref.data, val->elems, 32); FREE(val);
30669         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30670 }
30671
30672 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
30673         LDKCommitmentSigned this_ptr_conv;
30674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30675         this_ptr_conv.is_owned = false;
30676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30677         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30678         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30679         return ret_arr;
30680 }
30681
30682 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30683         LDKCommitmentSigned this_ptr_conv;
30684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30685         this_ptr_conv.is_owned = false;
30686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30687         LDKSignature val_ref;
30688         CHECK(val->arr_len == 64);
30689         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30690         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30691 }
30692
30693 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
30694         LDKCommitmentSigned this_ptr_conv;
30695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30696         this_ptr_conv.is_owned = false;
30697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30698         LDKCVec_SignatureZ val_constr;
30699         val_constr.datalen = val->arr_len;
30700         if (val_constr.datalen > 0)
30701                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30702         else
30703                 val_constr.data = NULL;
30704         int8_tArray* val_vals = (void*) val->elems;
30705         for (size_t m = 0; m < val_constr.datalen; m++) {
30706                 int8_tArray val_conv_12 = val_vals[m];
30707                 LDKSignature val_conv_12_ref;
30708                 CHECK(val_conv_12->arr_len == 64);
30709                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30710                 val_constr.data[m] = val_conv_12_ref;
30711         }
30712         FREE(val);
30713         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30714 }
30715
30716 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30717         LDKThirtyTwoBytes channel_id_arg_ref;
30718         CHECK(channel_id_arg->arr_len == 32);
30719         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30720         LDKSignature signature_arg_ref;
30721         CHECK(signature_arg->arr_len == 64);
30722         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30723         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30724         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30725         if (htlc_signatures_arg_constr.datalen > 0)
30726                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30727         else
30728                 htlc_signatures_arg_constr.data = NULL;
30729         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30730         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30731                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30732                 LDKSignature htlc_signatures_arg_conv_12_ref;
30733                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30734                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30735                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30736         }
30737         FREE(htlc_signatures_arg);
30738         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30739         uint32_t ret_ref = 0;
30740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30743         ret_ref = (uintptr_t)ret_var.inner;
30744         if (ret_var.is_owned) {
30745                 ret_ref |= 1;
30746         }
30747         return ret_ref;
30748 }
30749
30750 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30751         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30752 uint32_t ret_ref = 0;
30753 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30754 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30756 ret_ref = (uintptr_t)ret_var.inner;
30757 if (ret_var.is_owned) {
30758         ret_ref |= 1;
30759 }
30760         return ret_ref;
30761 }
30762 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
30763         LDKCommitmentSigned arg_conv;
30764         arg_conv.inner = (void*)(arg & (~1));
30765         arg_conv.is_owned = false;
30766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30767         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30768         return ret_conv;
30769 }
30770
30771 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
30772         LDKCommitmentSigned orig_conv;
30773         orig_conv.inner = (void*)(orig & (~1));
30774         orig_conv.is_owned = false;
30775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30776         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30777         uint32_t ret_ref = 0;
30778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30781         ret_ref = (uintptr_t)ret_var.inner;
30782         if (ret_var.is_owned) {
30783                 ret_ref |= 1;
30784         }
30785         return ret_ref;
30786 }
30787
30788 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
30789         LDKRevokeAndACK this_obj_conv;
30790         this_obj_conv.inner = (void*)(this_obj & (~1));
30791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30793         RevokeAndACK_free(this_obj_conv);
30794 }
30795
30796 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
30797         LDKRevokeAndACK this_ptr_conv;
30798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30799         this_ptr_conv.is_owned = false;
30800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30801         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30802         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30803         return ret_arr;
30804 }
30805
30806 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30807         LDKRevokeAndACK this_ptr_conv;
30808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30809         this_ptr_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         LDKThirtyTwoBytes val_ref;
30812         CHECK(val->arr_len == 32);
30813         memcpy(val_ref.data, val->elems, 32); FREE(val);
30814         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30815 }
30816
30817 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
30818         LDKRevokeAndACK this_ptr_conv;
30819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30820         this_ptr_conv.is_owned = false;
30821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30822         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30823         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30824         return ret_arr;
30825 }
30826
30827 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
30828         LDKRevokeAndACK this_ptr_conv;
30829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30830         this_ptr_conv.is_owned = false;
30831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30832         LDKThirtyTwoBytes val_ref;
30833         CHECK(val->arr_len == 32);
30834         memcpy(val_ref.data, val->elems, 32); FREE(val);
30835         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30836 }
30837
30838 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
30839         LDKRevokeAndACK this_ptr_conv;
30840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30841         this_ptr_conv.is_owned = false;
30842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30843         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30844         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30845         return ret_arr;
30846 }
30847
30848 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) {
30849         LDKRevokeAndACK this_ptr_conv;
30850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30851         this_ptr_conv.is_owned = false;
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30853         LDKPublicKey val_ref;
30854         CHECK(val->arr_len == 33);
30855         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30856         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30857 }
30858
30859 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) {
30860         LDKThirtyTwoBytes channel_id_arg_ref;
30861         CHECK(channel_id_arg->arr_len == 32);
30862         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30863         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30864         CHECK(per_commitment_secret_arg->arr_len == 32);
30865         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30866         LDKPublicKey next_per_commitment_point_arg_ref;
30867         CHECK(next_per_commitment_point_arg->arr_len == 33);
30868         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30869         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30870         uint32_t ret_ref = 0;
30871         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30872         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30874         ret_ref = (uintptr_t)ret_var.inner;
30875         if (ret_var.is_owned) {
30876                 ret_ref |= 1;
30877         }
30878         return ret_ref;
30879 }
30880
30881 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30882         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30883 uint32_t ret_ref = 0;
30884 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30885 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30886 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30887 ret_ref = (uintptr_t)ret_var.inner;
30888 if (ret_var.is_owned) {
30889         ret_ref |= 1;
30890 }
30891         return ret_ref;
30892 }
30893 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
30894         LDKRevokeAndACK arg_conv;
30895         arg_conv.inner = (void*)(arg & (~1));
30896         arg_conv.is_owned = false;
30897         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30898         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30899         return ret_conv;
30900 }
30901
30902 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
30903         LDKRevokeAndACK orig_conv;
30904         orig_conv.inner = (void*)(orig & (~1));
30905         orig_conv.is_owned = false;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30907         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30908         uint32_t ret_ref = 0;
30909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30912         ret_ref = (uintptr_t)ret_var.inner;
30913         if (ret_var.is_owned) {
30914                 ret_ref |= 1;
30915         }
30916         return ret_ref;
30917 }
30918
30919 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
30920         LDKUpdateFee this_obj_conv;
30921         this_obj_conv.inner = (void*)(this_obj & (~1));
30922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30924         UpdateFee_free(this_obj_conv);
30925 }
30926
30927 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
30928         LDKUpdateFee this_ptr_conv;
30929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30930         this_ptr_conv.is_owned = false;
30931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30932         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30933         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30934         return ret_arr;
30935 }
30936
30937 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30938         LDKUpdateFee this_ptr_conv;
30939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30940         this_ptr_conv.is_owned = false;
30941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30942         LDKThirtyTwoBytes val_ref;
30943         CHECK(val->arr_len == 32);
30944         memcpy(val_ref.data, val->elems, 32); FREE(val);
30945         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30946 }
30947
30948 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
30949         LDKUpdateFee this_ptr_conv;
30950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30951         this_ptr_conv.is_owned = false;
30952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30953         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30954         return ret_conv;
30955 }
30956
30957 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
30958         LDKUpdateFee this_ptr_conv;
30959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30960         this_ptr_conv.is_owned = false;
30961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30962         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
30963 }
30964
30965 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
30966         LDKThirtyTwoBytes channel_id_arg_ref;
30967         CHECK(channel_id_arg->arr_len == 32);
30968         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30969         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
30970         uint32_t ret_ref = 0;
30971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30974         ret_ref = (uintptr_t)ret_var.inner;
30975         if (ret_var.is_owned) {
30976                 ret_ref |= 1;
30977         }
30978         return ret_ref;
30979 }
30980
30981 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
30982         LDKUpdateFee ret_var = UpdateFee_clone(arg);
30983 uint32_t ret_ref = 0;
30984 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30985 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30986 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30987 ret_ref = (uintptr_t)ret_var.inner;
30988 if (ret_var.is_owned) {
30989         ret_ref |= 1;
30990 }
30991         return ret_ref;
30992 }
30993 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
30994         LDKUpdateFee arg_conv;
30995         arg_conv.inner = (void*)(arg & (~1));
30996         arg_conv.is_owned = false;
30997         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30998         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
30999         return ret_conv;
31000 }
31001
31002 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
31003         LDKUpdateFee orig_conv;
31004         orig_conv.inner = (void*)(orig & (~1));
31005         orig_conv.is_owned = false;
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31007         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
31008         uint32_t ret_ref = 0;
31009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31012         ret_ref = (uintptr_t)ret_var.inner;
31013         if (ret_var.is_owned) {
31014                 ret_ref |= 1;
31015         }
31016         return ret_ref;
31017 }
31018
31019 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
31020         LDKDataLossProtect this_obj_conv;
31021         this_obj_conv.inner = (void*)(this_obj & (~1));
31022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31024         DataLossProtect_free(this_obj_conv);
31025 }
31026
31027 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) {
31028         LDKDataLossProtect this_ptr_conv;
31029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31030         this_ptr_conv.is_owned = false;
31031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31032         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31033         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
31034         return ret_arr;
31035 }
31036
31037 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) {
31038         LDKDataLossProtect this_ptr_conv;
31039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31040         this_ptr_conv.is_owned = false;
31041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31042         LDKThirtyTwoBytes val_ref;
31043         CHECK(val->arr_len == 32);
31044         memcpy(val_ref.data, val->elems, 32); FREE(val);
31045         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
31046 }
31047
31048 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) {
31049         LDKDataLossProtect this_ptr_conv;
31050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31051         this_ptr_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31053         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31054         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
31055         return ret_arr;
31056 }
31057
31058 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) {
31059         LDKDataLossProtect this_ptr_conv;
31060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31061         this_ptr_conv.is_owned = false;
31062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31063         LDKPublicKey val_ref;
31064         CHECK(val->arr_len == 33);
31065         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31066         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
31067 }
31068
31069 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) {
31070         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
31071         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
31072         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
31073         LDKPublicKey my_current_per_commitment_point_arg_ref;
31074         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
31075         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);
31076         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
31077         uint32_t ret_ref = 0;
31078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31081         ret_ref = (uintptr_t)ret_var.inner;
31082         if (ret_var.is_owned) {
31083                 ret_ref |= 1;
31084         }
31085         return ret_ref;
31086 }
31087
31088 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
31089         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
31090 uint32_t ret_ref = 0;
31091 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31092 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31093 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31094 ret_ref = (uintptr_t)ret_var.inner;
31095 if (ret_var.is_owned) {
31096         ret_ref |= 1;
31097 }
31098         return ret_ref;
31099 }
31100 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
31101         LDKDataLossProtect arg_conv;
31102         arg_conv.inner = (void*)(arg & (~1));
31103         arg_conv.is_owned = false;
31104         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31105         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
31106         return ret_conv;
31107 }
31108
31109 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
31110         LDKDataLossProtect orig_conv;
31111         orig_conv.inner = (void*)(orig & (~1));
31112         orig_conv.is_owned = false;
31113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31114         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
31115         uint32_t ret_ref = 0;
31116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31119         ret_ref = (uintptr_t)ret_var.inner;
31120         if (ret_var.is_owned) {
31121                 ret_ref |= 1;
31122         }
31123         return ret_ref;
31124 }
31125
31126 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
31127         LDKChannelReestablish this_obj_conv;
31128         this_obj_conv.inner = (void*)(this_obj & (~1));
31129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31131         ChannelReestablish_free(this_obj_conv);
31132 }
31133
31134 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
31135         LDKChannelReestablish this_ptr_conv;
31136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31137         this_ptr_conv.is_owned = false;
31138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31139         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31140         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
31141         return ret_arr;
31142 }
31143
31144 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31145         LDKChannelReestablish this_ptr_conv;
31146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31147         this_ptr_conv.is_owned = false;
31148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31149         LDKThirtyTwoBytes val_ref;
31150         CHECK(val->arr_len == 32);
31151         memcpy(val_ref.data, val->elems, 32); FREE(val);
31152         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
31153 }
31154
31155 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
31156         LDKChannelReestablish this_ptr_conv;
31157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31158         this_ptr_conv.is_owned = false;
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31160         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
31161         return ret_conv;
31162 }
31163
31164 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) {
31165         LDKChannelReestablish this_ptr_conv;
31166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31167         this_ptr_conv.is_owned = false;
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31169         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
31170 }
31171
31172 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
31173         LDKChannelReestablish this_ptr_conv;
31174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31175         this_ptr_conv.is_owned = false;
31176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31177         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
31178         return ret_conv;
31179 }
31180
31181 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) {
31182         LDKChannelReestablish this_ptr_conv;
31183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31184         this_ptr_conv.is_owned = false;
31185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31186         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
31187 }
31188
31189 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
31190         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
31191 uint32_t ret_ref = 0;
31192 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31193 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31194 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31195 ret_ref = (uintptr_t)ret_var.inner;
31196 if (ret_var.is_owned) {
31197         ret_ref |= 1;
31198 }
31199         return ret_ref;
31200 }
31201 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
31202         LDKChannelReestablish arg_conv;
31203         arg_conv.inner = (void*)(arg & (~1));
31204         arg_conv.is_owned = false;
31205         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31206         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
31207         return ret_conv;
31208 }
31209
31210 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
31211         LDKChannelReestablish orig_conv;
31212         orig_conv.inner = (void*)(orig & (~1));
31213         orig_conv.is_owned = false;
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31215         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
31216         uint32_t ret_ref = 0;
31217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31220         ret_ref = (uintptr_t)ret_var.inner;
31221         if (ret_var.is_owned) {
31222                 ret_ref |= 1;
31223         }
31224         return ret_ref;
31225 }
31226
31227 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
31228         LDKAnnouncementSignatures this_obj_conv;
31229         this_obj_conv.inner = (void*)(this_obj & (~1));
31230         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31232         AnnouncementSignatures_free(this_obj_conv);
31233 }
31234
31235 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
31236         LDKAnnouncementSignatures this_ptr_conv;
31237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31238         this_ptr_conv.is_owned = false;
31239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31240         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31241         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
31242         return ret_arr;
31243 }
31244
31245 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31246         LDKAnnouncementSignatures this_ptr_conv;
31247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31248         this_ptr_conv.is_owned = false;
31249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31250         LDKThirtyTwoBytes val_ref;
31251         CHECK(val->arr_len == 32);
31252         memcpy(val_ref.data, val->elems, 32); FREE(val);
31253         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
31254 }
31255
31256 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
31257         LDKAnnouncementSignatures this_ptr_conv;
31258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31259         this_ptr_conv.is_owned = false;
31260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31261         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
31262         return ret_conv;
31263 }
31264
31265 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31266         LDKAnnouncementSignatures this_ptr_conv;
31267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31268         this_ptr_conv.is_owned = false;
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31270         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
31271 }
31272
31273 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
31274         LDKAnnouncementSignatures this_ptr_conv;
31275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31276         this_ptr_conv.is_owned = false;
31277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31278         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31279         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
31280         return ret_arr;
31281 }
31282
31283 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
31284         LDKAnnouncementSignatures this_ptr_conv;
31285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31286         this_ptr_conv.is_owned = false;
31287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31288         LDKSignature val_ref;
31289         CHECK(val->arr_len == 64);
31290         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31291         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
31292 }
31293
31294 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
31295         LDKAnnouncementSignatures this_ptr_conv;
31296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31297         this_ptr_conv.is_owned = false;
31298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31299         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31300         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
31301         return ret_arr;
31302 }
31303
31304 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
31305         LDKAnnouncementSignatures this_ptr_conv;
31306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31307         this_ptr_conv.is_owned = false;
31308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31309         LDKSignature val_ref;
31310         CHECK(val->arr_len == 64);
31311         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31312         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
31313 }
31314
31315 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) {
31316         LDKThirtyTwoBytes channel_id_arg_ref;
31317         CHECK(channel_id_arg->arr_len == 32);
31318         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31319         LDKSignature node_signature_arg_ref;
31320         CHECK(node_signature_arg->arr_len == 64);
31321         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
31322         LDKSignature bitcoin_signature_arg_ref;
31323         CHECK(bitcoin_signature_arg->arr_len == 64);
31324         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
31325         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
31326         uint32_t ret_ref = 0;
31327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31330         ret_ref = (uintptr_t)ret_var.inner;
31331         if (ret_var.is_owned) {
31332                 ret_ref |= 1;
31333         }
31334         return ret_ref;
31335 }
31336
31337 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
31338         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
31339 uint32_t ret_ref = 0;
31340 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31341 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31342 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31343 ret_ref = (uintptr_t)ret_var.inner;
31344 if (ret_var.is_owned) {
31345         ret_ref |= 1;
31346 }
31347         return ret_ref;
31348 }
31349 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
31350         LDKAnnouncementSignatures arg_conv;
31351         arg_conv.inner = (void*)(arg & (~1));
31352         arg_conv.is_owned = false;
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31354         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
31355         return ret_conv;
31356 }
31357
31358 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
31359         LDKAnnouncementSignatures orig_conv;
31360         orig_conv.inner = (void*)(orig & (~1));
31361         orig_conv.is_owned = false;
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31363         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
31364         uint32_t ret_ref = 0;
31365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31368         ret_ref = (uintptr_t)ret_var.inner;
31369         if (ret_var.is_owned) {
31370                 ret_ref |= 1;
31371         }
31372         return ret_ref;
31373 }
31374
31375 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
31376         if ((this_ptr & 1) != 0) return;
31377         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31378         CHECK_ACCESS(this_ptr_ptr);
31379         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
31380         FREE((void*)this_ptr);
31381         NetAddress_free(this_ptr_conv);
31382 }
31383
31384 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
31385         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31386         *ret_copy = NetAddress_clone(arg);
31387 uint32_t ret_ref = (uintptr_t)ret_copy;
31388         return ret_ref;
31389 }
31390 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
31391         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
31392         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
31393         return ret_conv;
31394 }
31395
31396 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
31397         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
31398         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31399         *ret_copy = NetAddress_clone(orig_conv);
31400         uint32_t ret_ref = (uintptr_t)ret_copy;
31401         return ret_ref;
31402 }
31403
31404 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
31405         LDKFourBytes addr_ref;
31406         CHECK(addr->arr_len == 4);
31407         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
31408         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31409         *ret_copy = NetAddress_ipv4(addr_ref, port);
31410         uint32_t ret_ref = (uintptr_t)ret_copy;
31411         return ret_ref;
31412 }
31413
31414 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
31415         LDKSixteenBytes addr_ref;
31416         CHECK(addr->arr_len == 16);
31417         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
31418         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31419         *ret_copy = NetAddress_ipv6(addr_ref, port);
31420         uint32_t ret_ref = (uintptr_t)ret_copy;
31421         return ret_ref;
31422 }
31423
31424 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
31425         LDKTwelveBytes a_ref;
31426         CHECK(a->arr_len == 12);
31427         memcpy(a_ref.data, a->elems, 12); FREE(a);
31428         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31429         *ret_copy = NetAddress_onion_v2(a_ref);
31430         uint32_t ret_ref = (uintptr_t)ret_copy;
31431         return ret_ref;
31432 }
31433
31434 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) {
31435         LDKThirtyTwoBytes ed25519_pubkey_ref;
31436         CHECK(ed25519_pubkey->arr_len == 32);
31437         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
31438         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31439         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
31440         uint32_t ret_ref = (uintptr_t)ret_copy;
31441         return ret_ref;
31442 }
31443
31444 uint32_t  __attribute__((export_name("TS_NetAddress_hostname"))) TS_NetAddress_hostname(uint32_t hostname, int16_t port) {
31445         LDKHostname hostname_conv;
31446         hostname_conv.inner = (void*)(hostname & (~1));
31447         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
31449         hostname_conv = Hostname_clone(&hostname_conv);
31450         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31451         *ret_copy = NetAddress_hostname(hostname_conv, port);
31452         uint32_t ret_ref = (uintptr_t)ret_copy;
31453         return ret_ref;
31454 }
31455
31456 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
31457         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
31458         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
31459         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31460         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31461         CVec_u8Z_free(ret_var);
31462         return ret_arr;
31463 }
31464
31465 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
31466         LDKu8slice ser_ref;
31467         ser_ref.datalen = ser->arr_len;
31468         ser_ref.data = ser->elems;
31469         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
31470         *ret_conv = NetAddress_read(ser_ref);
31471         FREE(ser);
31472         return (uint32_t)ret_conv;
31473 }
31474
31475 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
31476         LDKUnsignedNodeAnnouncement this_obj_conv;
31477         this_obj_conv.inner = (void*)(this_obj & (~1));
31478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31480         UnsignedNodeAnnouncement_free(this_obj_conv);
31481 }
31482
31483 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
31484         LDKUnsignedNodeAnnouncement this_ptr_conv;
31485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31486         this_ptr_conv.is_owned = false;
31487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31488         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
31489         uint32_t ret_ref = 0;
31490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31493         ret_ref = (uintptr_t)ret_var.inner;
31494         if (ret_var.is_owned) {
31495                 ret_ref |= 1;
31496         }
31497         return ret_ref;
31498 }
31499
31500 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31501         LDKUnsignedNodeAnnouncement this_ptr_conv;
31502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31503         this_ptr_conv.is_owned = false;
31504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31505         LDKNodeFeatures val_conv;
31506         val_conv.inner = (void*)(val & (~1));
31507         val_conv.is_owned = (val & 1) || (val == 0);
31508         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31509         val_conv = NodeFeatures_clone(&val_conv);
31510         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
31511 }
31512
31513 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
31514         LDKUnsignedNodeAnnouncement this_ptr_conv;
31515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31516         this_ptr_conv.is_owned = false;
31517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31518         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
31519         return ret_conv;
31520 }
31521
31522 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
31523         LDKUnsignedNodeAnnouncement this_ptr_conv;
31524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31525         this_ptr_conv.is_owned = false;
31526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31527         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
31528 }
31529
31530 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
31531         LDKUnsignedNodeAnnouncement this_ptr_conv;
31532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31533         this_ptr_conv.is_owned = false;
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31535         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31536         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
31537         return ret_arr;
31538 }
31539
31540 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
31541         LDKUnsignedNodeAnnouncement this_ptr_conv;
31542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31543         this_ptr_conv.is_owned = false;
31544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31545         LDKPublicKey val_ref;
31546         CHECK(val->arr_len == 33);
31547         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31548         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
31549 }
31550
31551 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
31552         LDKUnsignedNodeAnnouncement this_ptr_conv;
31553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31554         this_ptr_conv.is_owned = false;
31555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31556         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
31557         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
31558         return ret_arr;
31559 }
31560
31561 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
31562         LDKUnsignedNodeAnnouncement this_ptr_conv;
31563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31564         this_ptr_conv.is_owned = false;
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31566         LDKThreeBytes val_ref;
31567         CHECK(val->arr_len == 3);
31568         memcpy(val_ref.data, val->elems, 3); FREE(val);
31569         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
31570 }
31571
31572 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
31573         LDKUnsignedNodeAnnouncement this_ptr_conv;
31574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31575         this_ptr_conv.is_owned = false;
31576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31577         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31578         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
31579         return ret_arr;
31580 }
31581
31582 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
31583         LDKUnsignedNodeAnnouncement this_ptr_conv;
31584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31585         this_ptr_conv.is_owned = false;
31586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31587         LDKThirtyTwoBytes val_ref;
31588         CHECK(val->arr_len == 32);
31589         memcpy(val_ref.data, val->elems, 32); FREE(val);
31590         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
31591 }
31592
31593 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
31594         LDKUnsignedNodeAnnouncement this_ptr_conv;
31595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31596         this_ptr_conv.is_owned = false;
31597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31598         LDKCVec_NetAddressZ val_constr;
31599         val_constr.datalen = val->arr_len;
31600         if (val_constr.datalen > 0)
31601                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31602         else
31603                 val_constr.data = NULL;
31604         uint32_t* val_vals = val->elems;
31605         for (size_t m = 0; m < val_constr.datalen; m++) {
31606                 uint32_t val_conv_12 = val_vals[m];
31607                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
31608                 CHECK_ACCESS(val_conv_12_ptr);
31609                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
31610                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
31611                 val_constr.data[m] = val_conv_12_conv;
31612         }
31613         FREE(val);
31614         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
31615 }
31616
31617 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
31618         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
31619 uint32_t ret_ref = 0;
31620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31623 ret_ref = (uintptr_t)ret_var.inner;
31624 if (ret_var.is_owned) {
31625         ret_ref |= 1;
31626 }
31627         return ret_ref;
31628 }
31629 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
31630         LDKUnsignedNodeAnnouncement arg_conv;
31631         arg_conv.inner = (void*)(arg & (~1));
31632         arg_conv.is_owned = false;
31633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31634         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
31635         return ret_conv;
31636 }
31637
31638 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
31639         LDKUnsignedNodeAnnouncement orig_conv;
31640         orig_conv.inner = (void*)(orig & (~1));
31641         orig_conv.is_owned = false;
31642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31643         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
31644         uint32_t ret_ref = 0;
31645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31648         ret_ref = (uintptr_t)ret_var.inner;
31649         if (ret_var.is_owned) {
31650                 ret_ref |= 1;
31651         }
31652         return ret_ref;
31653 }
31654
31655 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
31656         LDKNodeAnnouncement this_obj_conv;
31657         this_obj_conv.inner = (void*)(this_obj & (~1));
31658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31660         NodeAnnouncement_free(this_obj_conv);
31661 }
31662
31663 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
31664         LDKNodeAnnouncement this_ptr_conv;
31665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31666         this_ptr_conv.is_owned = false;
31667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31668         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31669         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31670         return ret_arr;
31671 }
31672
31673 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
31674         LDKNodeAnnouncement this_ptr_conv;
31675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31676         this_ptr_conv.is_owned = false;
31677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31678         LDKSignature val_ref;
31679         CHECK(val->arr_len == 64);
31680         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31681         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31682 }
31683
31684 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
31685         LDKNodeAnnouncement this_ptr_conv;
31686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31687         this_ptr_conv.is_owned = false;
31688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31689         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31690         uint32_t ret_ref = 0;
31691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31694         ret_ref = (uintptr_t)ret_var.inner;
31695         if (ret_var.is_owned) {
31696                 ret_ref |= 1;
31697         }
31698         return ret_ref;
31699 }
31700
31701 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31702         LDKNodeAnnouncement this_ptr_conv;
31703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31704         this_ptr_conv.is_owned = false;
31705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31706         LDKUnsignedNodeAnnouncement val_conv;
31707         val_conv.inner = (void*)(val & (~1));
31708         val_conv.is_owned = (val & 1) || (val == 0);
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31710         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31711         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31712 }
31713
31714 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
31715         LDKSignature signature_arg_ref;
31716         CHECK(signature_arg->arr_len == 64);
31717         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31718         LDKUnsignedNodeAnnouncement contents_arg_conv;
31719         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31720         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31721         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31722         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31723         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31724         uint32_t ret_ref = 0;
31725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31728         ret_ref = (uintptr_t)ret_var.inner;
31729         if (ret_var.is_owned) {
31730                 ret_ref |= 1;
31731         }
31732         return ret_ref;
31733 }
31734
31735 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31736         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31737 uint32_t ret_ref = 0;
31738 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31739 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31740 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31741 ret_ref = (uintptr_t)ret_var.inner;
31742 if (ret_var.is_owned) {
31743         ret_ref |= 1;
31744 }
31745         return ret_ref;
31746 }
31747 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
31748         LDKNodeAnnouncement arg_conv;
31749         arg_conv.inner = (void*)(arg & (~1));
31750         arg_conv.is_owned = false;
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31752         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31753         return ret_conv;
31754 }
31755
31756 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
31757         LDKNodeAnnouncement orig_conv;
31758         orig_conv.inner = (void*)(orig & (~1));
31759         orig_conv.is_owned = false;
31760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31761         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31762         uint32_t ret_ref = 0;
31763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31766         ret_ref = (uintptr_t)ret_var.inner;
31767         if (ret_var.is_owned) {
31768                 ret_ref |= 1;
31769         }
31770         return ret_ref;
31771 }
31772
31773 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
31774         LDKUnsignedChannelAnnouncement this_obj_conv;
31775         this_obj_conv.inner = (void*)(this_obj & (~1));
31776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31778         UnsignedChannelAnnouncement_free(this_obj_conv);
31779 }
31780
31781 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
31782         LDKUnsignedChannelAnnouncement this_ptr_conv;
31783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31784         this_ptr_conv.is_owned = false;
31785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31786         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31787         uint32_t ret_ref = 0;
31788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31791         ret_ref = (uintptr_t)ret_var.inner;
31792         if (ret_var.is_owned) {
31793                 ret_ref |= 1;
31794         }
31795         return ret_ref;
31796 }
31797
31798 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31799         LDKUnsignedChannelAnnouncement this_ptr_conv;
31800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31801         this_ptr_conv.is_owned = false;
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31803         LDKChannelFeatures val_conv;
31804         val_conv.inner = (void*)(val & (~1));
31805         val_conv.is_owned = (val & 1) || (val == 0);
31806         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31807         val_conv = ChannelFeatures_clone(&val_conv);
31808         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31809 }
31810
31811 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
31812         LDKUnsignedChannelAnnouncement this_ptr_conv;
31813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31814         this_ptr_conv.is_owned = false;
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31816         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31817         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31818         return ret_arr;
31819 }
31820
31821 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31822         LDKUnsignedChannelAnnouncement this_ptr_conv;
31823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31824         this_ptr_conv.is_owned = false;
31825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31826         LDKThirtyTwoBytes val_ref;
31827         CHECK(val->arr_len == 32);
31828         memcpy(val_ref.data, val->elems, 32); FREE(val);
31829         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31830 }
31831
31832 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
31833         LDKUnsignedChannelAnnouncement this_ptr_conv;
31834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31835         this_ptr_conv.is_owned = false;
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31837         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31838         return ret_conv;
31839 }
31840
31841 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31842         LDKUnsignedChannelAnnouncement this_ptr_conv;
31843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31844         this_ptr_conv.is_owned = false;
31845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31846         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31847 }
31848
31849 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
31850         LDKUnsignedChannelAnnouncement this_ptr_conv;
31851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31852         this_ptr_conv.is_owned = false;
31853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31854         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31855         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31856         return ret_arr;
31857 }
31858
31859 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
31860         LDKUnsignedChannelAnnouncement this_ptr_conv;
31861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31862         this_ptr_conv.is_owned = false;
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31864         LDKPublicKey val_ref;
31865         CHECK(val->arr_len == 33);
31866         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31867         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31868 }
31869
31870 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
31871         LDKUnsignedChannelAnnouncement this_ptr_conv;
31872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31873         this_ptr_conv.is_owned = false;
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31875         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31876         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31877         return ret_arr;
31878 }
31879
31880 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
31881         LDKUnsignedChannelAnnouncement this_ptr_conv;
31882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31883         this_ptr_conv.is_owned = false;
31884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31885         LDKPublicKey val_ref;
31886         CHECK(val->arr_len == 33);
31887         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31888         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31889 }
31890
31891 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
31892         LDKUnsignedChannelAnnouncement this_ptr_conv;
31893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31894         this_ptr_conv.is_owned = false;
31895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31896         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31897         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31898         return ret_arr;
31899 }
31900
31901 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
31902         LDKUnsignedChannelAnnouncement this_ptr_conv;
31903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31904         this_ptr_conv.is_owned = false;
31905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31906         LDKPublicKey val_ref;
31907         CHECK(val->arr_len == 33);
31908         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31909         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31910 }
31911
31912 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
31913         LDKUnsignedChannelAnnouncement this_ptr_conv;
31914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31915         this_ptr_conv.is_owned = false;
31916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31917         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31918         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31919         return ret_arr;
31920 }
31921
31922 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
31923         LDKUnsignedChannelAnnouncement this_ptr_conv;
31924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31925         this_ptr_conv.is_owned = false;
31926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31927         LDKPublicKey val_ref;
31928         CHECK(val->arr_len == 33);
31929         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31930         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31931 }
31932
31933 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31934         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31935 uint32_t ret_ref = 0;
31936 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31937 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31938 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31939 ret_ref = (uintptr_t)ret_var.inner;
31940 if (ret_var.is_owned) {
31941         ret_ref |= 1;
31942 }
31943         return ret_ref;
31944 }
31945 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
31946         LDKUnsignedChannelAnnouncement arg_conv;
31947         arg_conv.inner = (void*)(arg & (~1));
31948         arg_conv.is_owned = false;
31949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31950         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
31951         return ret_conv;
31952 }
31953
31954 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
31955         LDKUnsignedChannelAnnouncement orig_conv;
31956         orig_conv.inner = (void*)(orig & (~1));
31957         orig_conv.is_owned = false;
31958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31959         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
31960         uint32_t ret_ref = 0;
31961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31964         ret_ref = (uintptr_t)ret_var.inner;
31965         if (ret_var.is_owned) {
31966                 ret_ref |= 1;
31967         }
31968         return ret_ref;
31969 }
31970
31971 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
31972         LDKChannelAnnouncement this_obj_conv;
31973         this_obj_conv.inner = (void*)(this_obj & (~1));
31974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31976         ChannelAnnouncement_free(this_obj_conv);
31977 }
31978
31979 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
31980         LDKChannelAnnouncement this_ptr_conv;
31981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31982         this_ptr_conv.is_owned = false;
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31984         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31985         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
31986         return ret_arr;
31987 }
31988
31989 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
31990         LDKChannelAnnouncement this_ptr_conv;
31991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31992         this_ptr_conv.is_owned = false;
31993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31994         LDKSignature val_ref;
31995         CHECK(val->arr_len == 64);
31996         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31997         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
31998 }
31999
32000 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
32001         LDKChannelAnnouncement this_ptr_conv;
32002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32003         this_ptr_conv.is_owned = false;
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32005         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32006         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
32007         return ret_arr;
32008 }
32009
32010 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
32011         LDKChannelAnnouncement this_ptr_conv;
32012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32013         this_ptr_conv.is_owned = false;
32014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32015         LDKSignature val_ref;
32016         CHECK(val->arr_len == 64);
32017         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32018         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
32019 }
32020
32021 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
32022         LDKChannelAnnouncement this_ptr_conv;
32023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32024         this_ptr_conv.is_owned = false;
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32026         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32027         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
32028         return ret_arr;
32029 }
32030
32031 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
32032         LDKChannelAnnouncement this_ptr_conv;
32033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32034         this_ptr_conv.is_owned = false;
32035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32036         LDKSignature val_ref;
32037         CHECK(val->arr_len == 64);
32038         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32039         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
32040 }
32041
32042 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
32043         LDKChannelAnnouncement this_ptr_conv;
32044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32045         this_ptr_conv.is_owned = false;
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32047         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32048         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
32049         return ret_arr;
32050 }
32051
32052 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
32053         LDKChannelAnnouncement this_ptr_conv;
32054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32055         this_ptr_conv.is_owned = false;
32056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32057         LDKSignature val_ref;
32058         CHECK(val->arr_len == 64);
32059         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32060         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
32061 }
32062
32063 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
32064         LDKChannelAnnouncement this_ptr_conv;
32065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32066         this_ptr_conv.is_owned = false;
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32068         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
32069         uint32_t ret_ref = 0;
32070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32073         ret_ref = (uintptr_t)ret_var.inner;
32074         if (ret_var.is_owned) {
32075                 ret_ref |= 1;
32076         }
32077         return ret_ref;
32078 }
32079
32080 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
32081         LDKChannelAnnouncement this_ptr_conv;
32082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32083         this_ptr_conv.is_owned = false;
32084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32085         LDKUnsignedChannelAnnouncement val_conv;
32086         val_conv.inner = (void*)(val & (~1));
32087         val_conv.is_owned = (val & 1) || (val == 0);
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32089         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
32090         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
32091 }
32092
32093 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) {
32094         LDKSignature node_signature_1_arg_ref;
32095         CHECK(node_signature_1_arg->arr_len == 64);
32096         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
32097         LDKSignature node_signature_2_arg_ref;
32098         CHECK(node_signature_2_arg->arr_len == 64);
32099         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
32100         LDKSignature bitcoin_signature_1_arg_ref;
32101         CHECK(bitcoin_signature_1_arg->arr_len == 64);
32102         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
32103         LDKSignature bitcoin_signature_2_arg_ref;
32104         CHECK(bitcoin_signature_2_arg->arr_len == 64);
32105         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
32106         LDKUnsignedChannelAnnouncement contents_arg_conv;
32107         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32108         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32110         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
32111         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);
32112         uint32_t ret_ref = 0;
32113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32116         ret_ref = (uintptr_t)ret_var.inner;
32117         if (ret_var.is_owned) {
32118                 ret_ref |= 1;
32119         }
32120         return ret_ref;
32121 }
32122
32123 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
32124         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
32125 uint32_t ret_ref = 0;
32126 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32127 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32128 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32129 ret_ref = (uintptr_t)ret_var.inner;
32130 if (ret_var.is_owned) {
32131         ret_ref |= 1;
32132 }
32133         return ret_ref;
32134 }
32135 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
32136         LDKChannelAnnouncement arg_conv;
32137         arg_conv.inner = (void*)(arg & (~1));
32138         arg_conv.is_owned = false;
32139         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32140         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
32141         return ret_conv;
32142 }
32143
32144 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
32145         LDKChannelAnnouncement orig_conv;
32146         orig_conv.inner = (void*)(orig & (~1));
32147         orig_conv.is_owned = false;
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32149         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
32150         uint32_t ret_ref = 0;
32151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32154         ret_ref = (uintptr_t)ret_var.inner;
32155         if (ret_var.is_owned) {
32156                 ret_ref |= 1;
32157         }
32158         return ret_ref;
32159 }
32160
32161 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
32162         LDKUnsignedChannelUpdate this_obj_conv;
32163         this_obj_conv.inner = (void*)(this_obj & (~1));
32164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32166         UnsignedChannelUpdate_free(this_obj_conv);
32167 }
32168
32169 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
32170         LDKUnsignedChannelUpdate this_ptr_conv;
32171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32172         this_ptr_conv.is_owned = false;
32173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32174         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32175         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
32176         return ret_arr;
32177 }
32178
32179 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32180         LDKUnsignedChannelUpdate this_ptr_conv;
32181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32182         this_ptr_conv.is_owned = false;
32183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32184         LDKThirtyTwoBytes val_ref;
32185         CHECK(val->arr_len == 32);
32186         memcpy(val_ref.data, val->elems, 32); FREE(val);
32187         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
32188 }
32189
32190 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
32191         LDKUnsignedChannelUpdate this_ptr_conv;
32192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32193         this_ptr_conv.is_owned = false;
32194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32195         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
32196         return ret_conv;
32197 }
32198
32199 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
32200         LDKUnsignedChannelUpdate this_ptr_conv;
32201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32202         this_ptr_conv.is_owned = false;
32203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32204         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
32205 }
32206
32207 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
32208         LDKUnsignedChannelUpdate this_ptr_conv;
32209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32210         this_ptr_conv.is_owned = false;
32211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32212         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
32213         return ret_conv;
32214 }
32215
32216 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
32217         LDKUnsignedChannelUpdate this_ptr_conv;
32218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32219         this_ptr_conv.is_owned = false;
32220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32221         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
32222 }
32223
32224 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
32225         LDKUnsignedChannelUpdate this_ptr_conv;
32226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32227         this_ptr_conv.is_owned = false;
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32229         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
32230         return ret_conv;
32231 }
32232
32233 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
32234         LDKUnsignedChannelUpdate this_ptr_conv;
32235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32236         this_ptr_conv.is_owned = false;
32237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32238         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
32239 }
32240
32241 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
32242         LDKUnsignedChannelUpdate this_ptr_conv;
32243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32244         this_ptr_conv.is_owned = false;
32245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32246         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
32247         return ret_conv;
32248 }
32249
32250 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32251         LDKUnsignedChannelUpdate this_ptr_conv;
32252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32253         this_ptr_conv.is_owned = false;
32254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32255         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
32256 }
32257
32258 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
32259         LDKUnsignedChannelUpdate this_ptr_conv;
32260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32261         this_ptr_conv.is_owned = false;
32262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32263         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
32264         return ret_conv;
32265 }
32266
32267 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32268         LDKUnsignedChannelUpdate this_ptr_conv;
32269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32270         this_ptr_conv.is_owned = false;
32271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32272         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
32273 }
32274
32275 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_get_htlc_maximum_msat(uint32_t this_ptr) {
32276         LDKUnsignedChannelUpdate this_ptr_conv;
32277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32278         this_ptr_conv.is_owned = false;
32279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32280         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
32281         return ret_conv;
32282 }
32283
32284 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
32285         LDKUnsignedChannelUpdate this_ptr_conv;
32286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32287         this_ptr_conv.is_owned = false;
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32289         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
32290 }
32291
32292 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
32293         LDKUnsignedChannelUpdate this_ptr_conv;
32294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32295         this_ptr_conv.is_owned = false;
32296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32297         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
32298         return ret_conv;
32299 }
32300
32301 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
32302         LDKUnsignedChannelUpdate this_ptr_conv;
32303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32304         this_ptr_conv.is_owned = false;
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32306         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
32307 }
32308
32309 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
32310         LDKUnsignedChannelUpdate this_ptr_conv;
32311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32312         this_ptr_conv.is_owned = false;
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32314         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
32315         return ret_conv;
32316 }
32317
32318 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
32319         LDKUnsignedChannelUpdate this_ptr_conv;
32320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32321         this_ptr_conv.is_owned = false;
32322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32323         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
32324 }
32325
32326 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
32327         LDKUnsignedChannelUpdate this_ptr_conv;
32328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32329         this_ptr_conv.is_owned = false;
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32331         LDKCVec_u8Z val_ref;
32332         val_ref.datalen = val->arr_len;
32333         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32334         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32335         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
32336 }
32337
32338 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_new"))) TS_UnsignedChannelUpdate_new(int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
32339         LDKThirtyTwoBytes chain_hash_arg_ref;
32340         CHECK(chain_hash_arg->arr_len == 32);
32341         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32342         LDKCVec_u8Z excess_data_arg_ref;
32343         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
32344         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32345         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
32346         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
32347         uint32_t ret_ref = 0;
32348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32351         ret_ref = (uintptr_t)ret_var.inner;
32352         if (ret_var.is_owned) {
32353                 ret_ref |= 1;
32354         }
32355         return ret_ref;
32356 }
32357
32358 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
32359         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
32360 uint32_t ret_ref = 0;
32361 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32362 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32363 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32364 ret_ref = (uintptr_t)ret_var.inner;
32365 if (ret_var.is_owned) {
32366         ret_ref |= 1;
32367 }
32368         return ret_ref;
32369 }
32370 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
32371         LDKUnsignedChannelUpdate arg_conv;
32372         arg_conv.inner = (void*)(arg & (~1));
32373         arg_conv.is_owned = false;
32374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32375         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
32376         return ret_conv;
32377 }
32378
32379 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
32380         LDKUnsignedChannelUpdate orig_conv;
32381         orig_conv.inner = (void*)(orig & (~1));
32382         orig_conv.is_owned = false;
32383         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32384         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
32385         uint32_t ret_ref = 0;
32386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32389         ret_ref = (uintptr_t)ret_var.inner;
32390         if (ret_var.is_owned) {
32391                 ret_ref |= 1;
32392         }
32393         return ret_ref;
32394 }
32395
32396 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
32397         LDKChannelUpdate this_obj_conv;
32398         this_obj_conv.inner = (void*)(this_obj & (~1));
32399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32401         ChannelUpdate_free(this_obj_conv);
32402 }
32403
32404 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
32405         LDKChannelUpdate this_ptr_conv;
32406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32407         this_ptr_conv.is_owned = false;
32408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32409         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32410         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
32411         return ret_arr;
32412 }
32413
32414 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
32415         LDKChannelUpdate this_ptr_conv;
32416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32417         this_ptr_conv.is_owned = false;
32418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32419         LDKSignature val_ref;
32420         CHECK(val->arr_len == 64);
32421         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32422         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
32423 }
32424
32425 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
32426         LDKChannelUpdate this_ptr_conv;
32427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32428         this_ptr_conv.is_owned = false;
32429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32430         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
32431         uint32_t ret_ref = 0;
32432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32435         ret_ref = (uintptr_t)ret_var.inner;
32436         if (ret_var.is_owned) {
32437                 ret_ref |= 1;
32438         }
32439         return ret_ref;
32440 }
32441
32442 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
32443         LDKChannelUpdate this_ptr_conv;
32444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32445         this_ptr_conv.is_owned = false;
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32447         LDKUnsignedChannelUpdate val_conv;
32448         val_conv.inner = (void*)(val & (~1));
32449         val_conv.is_owned = (val & 1) || (val == 0);
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32451         val_conv = UnsignedChannelUpdate_clone(&val_conv);
32452         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
32453 }
32454
32455 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
32456         LDKSignature signature_arg_ref;
32457         CHECK(signature_arg->arr_len == 64);
32458         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
32459         LDKUnsignedChannelUpdate contents_arg_conv;
32460         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32461         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32462         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32463         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
32464         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
32465         uint32_t ret_ref = 0;
32466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32469         ret_ref = (uintptr_t)ret_var.inner;
32470         if (ret_var.is_owned) {
32471                 ret_ref |= 1;
32472         }
32473         return ret_ref;
32474 }
32475
32476 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
32477         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
32478 uint32_t ret_ref = 0;
32479 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32480 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32481 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32482 ret_ref = (uintptr_t)ret_var.inner;
32483 if (ret_var.is_owned) {
32484         ret_ref |= 1;
32485 }
32486         return ret_ref;
32487 }
32488 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
32489         LDKChannelUpdate arg_conv;
32490         arg_conv.inner = (void*)(arg & (~1));
32491         arg_conv.is_owned = false;
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32493         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
32494         return ret_conv;
32495 }
32496
32497 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
32498         LDKChannelUpdate orig_conv;
32499         orig_conv.inner = (void*)(orig & (~1));
32500         orig_conv.is_owned = false;
32501         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32502         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
32503         uint32_t ret_ref = 0;
32504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32507         ret_ref = (uintptr_t)ret_var.inner;
32508         if (ret_var.is_owned) {
32509                 ret_ref |= 1;
32510         }
32511         return ret_ref;
32512 }
32513
32514 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
32515         LDKQueryChannelRange this_obj_conv;
32516         this_obj_conv.inner = (void*)(this_obj & (~1));
32517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32519         QueryChannelRange_free(this_obj_conv);
32520 }
32521
32522 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
32523         LDKQueryChannelRange this_ptr_conv;
32524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32525         this_ptr_conv.is_owned = false;
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32527         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32528         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
32529         return ret_arr;
32530 }
32531
32532 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32533         LDKQueryChannelRange this_ptr_conv;
32534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32535         this_ptr_conv.is_owned = false;
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         LDKThirtyTwoBytes val_ref;
32538         CHECK(val->arr_len == 32);
32539         memcpy(val_ref.data, val->elems, 32); FREE(val);
32540         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32541 }
32542
32543 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
32544         LDKQueryChannelRange this_ptr_conv;
32545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32546         this_ptr_conv.is_owned = false;
32547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32548         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
32549         return ret_conv;
32550 }
32551
32552 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32553         LDKQueryChannelRange this_ptr_conv;
32554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32555         this_ptr_conv.is_owned = false;
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32557         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
32558 }
32559
32560 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32561         LDKQueryChannelRange this_ptr_conv;
32562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32563         this_ptr_conv.is_owned = false;
32564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32565         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
32566         return ret_conv;
32567 }
32568
32569 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32570         LDKQueryChannelRange this_ptr_conv;
32571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32572         this_ptr_conv.is_owned = false;
32573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32574         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32575 }
32576
32577 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) {
32578         LDKThirtyTwoBytes chain_hash_arg_ref;
32579         CHECK(chain_hash_arg->arr_len == 32);
32580         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32581         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
32582         uint32_t ret_ref = 0;
32583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32586         ret_ref = (uintptr_t)ret_var.inner;
32587         if (ret_var.is_owned) {
32588                 ret_ref |= 1;
32589         }
32590         return ret_ref;
32591 }
32592
32593 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
32594         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
32595 uint32_t ret_ref = 0;
32596 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32597 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32599 ret_ref = (uintptr_t)ret_var.inner;
32600 if (ret_var.is_owned) {
32601         ret_ref |= 1;
32602 }
32603         return ret_ref;
32604 }
32605 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
32606         LDKQueryChannelRange arg_conv;
32607         arg_conv.inner = (void*)(arg & (~1));
32608         arg_conv.is_owned = false;
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32610         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
32611         return ret_conv;
32612 }
32613
32614 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
32615         LDKQueryChannelRange orig_conv;
32616         orig_conv.inner = (void*)(orig & (~1));
32617         orig_conv.is_owned = false;
32618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32619         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
32620         uint32_t ret_ref = 0;
32621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32624         ret_ref = (uintptr_t)ret_var.inner;
32625         if (ret_var.is_owned) {
32626                 ret_ref |= 1;
32627         }
32628         return ret_ref;
32629 }
32630
32631 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
32632         LDKReplyChannelRange this_obj_conv;
32633         this_obj_conv.inner = (void*)(this_obj & (~1));
32634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32636         ReplyChannelRange_free(this_obj_conv);
32637 }
32638
32639 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
32640         LDKReplyChannelRange this_ptr_conv;
32641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32642         this_ptr_conv.is_owned = false;
32643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32644         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32645         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
32646         return ret_arr;
32647 }
32648
32649 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32650         LDKReplyChannelRange this_ptr_conv;
32651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32652         this_ptr_conv.is_owned = false;
32653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32654         LDKThirtyTwoBytes val_ref;
32655         CHECK(val->arr_len == 32);
32656         memcpy(val_ref.data, val->elems, 32); FREE(val);
32657         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32658 }
32659
32660 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
32661         LDKReplyChannelRange this_ptr_conv;
32662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32663         this_ptr_conv.is_owned = false;
32664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32665         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
32666         return ret_conv;
32667 }
32668
32669 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32670         LDKReplyChannelRange this_ptr_conv;
32671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32672         this_ptr_conv.is_owned = false;
32673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32674         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
32675 }
32676
32677 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32678         LDKReplyChannelRange this_ptr_conv;
32679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32680         this_ptr_conv.is_owned = false;
32681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32682         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
32683         return ret_conv;
32684 }
32685
32686 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32687         LDKReplyChannelRange this_ptr_conv;
32688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32689         this_ptr_conv.is_owned = false;
32690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32691         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32692 }
32693
32694 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
32695         LDKReplyChannelRange this_ptr_conv;
32696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32697         this_ptr_conv.is_owned = false;
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32699         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32700         return ret_conv;
32701 }
32702
32703 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
32704         LDKReplyChannelRange this_ptr_conv;
32705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32706         this_ptr_conv.is_owned = false;
32707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32708         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32709 }
32710
32711 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32712         LDKReplyChannelRange this_ptr_conv;
32713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32714         this_ptr_conv.is_owned = false;
32715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32716         LDKCVec_u64Z val_constr;
32717         val_constr.datalen = val->arr_len;
32718         if (val_constr.datalen > 0)
32719                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32720         else
32721                 val_constr.data = NULL;
32722         int64_t* val_vals = val->elems;
32723         for (size_t i = 0; i < val_constr.datalen; i++) {
32724                 int64_t val_conv_8 = val_vals[i];
32725                 val_constr.data[i] = val_conv_8;
32726         }
32727         FREE(val);
32728         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32729 }
32730
32731 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) {
32732         LDKThirtyTwoBytes chain_hash_arg_ref;
32733         CHECK(chain_hash_arg->arr_len == 32);
32734         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32735         LDKCVec_u64Z short_channel_ids_arg_constr;
32736         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32737         if (short_channel_ids_arg_constr.datalen > 0)
32738                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32739         else
32740                 short_channel_ids_arg_constr.data = NULL;
32741         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32742         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32743                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32744                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32745         }
32746         FREE(short_channel_ids_arg);
32747         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
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 ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32760         LDKReplyChannelRange ret_var = ReplyChannelRange_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_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
32772         LDKReplyChannelRange 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_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32777         return ret_conv;
32778 }
32779
32780 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
32781         LDKReplyChannelRange 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         LDKReplyChannelRange ret_var = ReplyChannelRange_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 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
32798         LDKQueryShortChannelIds this_obj_conv;
32799         this_obj_conv.inner = (void*)(this_obj & (~1));
32800         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32802         QueryShortChannelIds_free(this_obj_conv);
32803 }
32804
32805 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
32806         LDKQueryShortChannelIds this_ptr_conv;
32807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32808         this_ptr_conv.is_owned = false;
32809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32810         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32811         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32812         return ret_arr;
32813 }
32814
32815 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32816         LDKQueryShortChannelIds this_ptr_conv;
32817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32818         this_ptr_conv.is_owned = false;
32819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32820         LDKThirtyTwoBytes val_ref;
32821         CHECK(val->arr_len == 32);
32822         memcpy(val_ref.data, val->elems, 32); FREE(val);
32823         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32824 }
32825
32826 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32827         LDKQueryShortChannelIds this_ptr_conv;
32828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32829         this_ptr_conv.is_owned = false;
32830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32831         LDKCVec_u64Z val_constr;
32832         val_constr.datalen = val->arr_len;
32833         if (val_constr.datalen > 0)
32834                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32835         else
32836                 val_constr.data = NULL;
32837         int64_t* val_vals = val->elems;
32838         for (size_t i = 0; i < val_constr.datalen; i++) {
32839                 int64_t val_conv_8 = val_vals[i];
32840                 val_constr.data[i] = val_conv_8;
32841         }
32842         FREE(val);
32843         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32844 }
32845
32846 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32847         LDKThirtyTwoBytes chain_hash_arg_ref;
32848         CHECK(chain_hash_arg->arr_len == 32);
32849         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32850         LDKCVec_u64Z short_channel_ids_arg_constr;
32851         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32852         if (short_channel_ids_arg_constr.datalen > 0)
32853                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32854         else
32855                 short_channel_ids_arg_constr.data = NULL;
32856         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32857         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32858                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32859                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32860         }
32861         FREE(short_channel_ids_arg);
32862         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32863         uint32_t ret_ref = 0;
32864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32867         ret_ref = (uintptr_t)ret_var.inner;
32868         if (ret_var.is_owned) {
32869                 ret_ref |= 1;
32870         }
32871         return ret_ref;
32872 }
32873
32874 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32875         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32876 uint32_t ret_ref = 0;
32877 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32878 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32879 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32880 ret_ref = (uintptr_t)ret_var.inner;
32881 if (ret_var.is_owned) {
32882         ret_ref |= 1;
32883 }
32884         return ret_ref;
32885 }
32886 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
32887         LDKQueryShortChannelIds arg_conv;
32888         arg_conv.inner = (void*)(arg & (~1));
32889         arg_conv.is_owned = false;
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32891         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
32892         return ret_conv;
32893 }
32894
32895 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
32896         LDKQueryShortChannelIds orig_conv;
32897         orig_conv.inner = (void*)(orig & (~1));
32898         orig_conv.is_owned = false;
32899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32900         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
32901         uint32_t ret_ref = 0;
32902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32905         ret_ref = (uintptr_t)ret_var.inner;
32906         if (ret_var.is_owned) {
32907                 ret_ref |= 1;
32908         }
32909         return ret_ref;
32910 }
32911
32912 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
32913         LDKReplyShortChannelIdsEnd this_obj_conv;
32914         this_obj_conv.inner = (void*)(this_obj & (~1));
32915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32917         ReplyShortChannelIdsEnd_free(this_obj_conv);
32918 }
32919
32920 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
32921         LDKReplyShortChannelIdsEnd this_ptr_conv;
32922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32923         this_ptr_conv.is_owned = false;
32924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32925         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32926         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
32927         return ret_arr;
32928 }
32929
32930 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32931         LDKReplyShortChannelIdsEnd this_ptr_conv;
32932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32933         this_ptr_conv.is_owned = false;
32934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32935         LDKThirtyTwoBytes val_ref;
32936         CHECK(val->arr_len == 32);
32937         memcpy(val_ref.data, val->elems, 32); FREE(val);
32938         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
32939 }
32940
32941 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
32942         LDKReplyShortChannelIdsEnd this_ptr_conv;
32943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32944         this_ptr_conv.is_owned = false;
32945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32946         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
32947         return ret_conv;
32948 }
32949
32950 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
32951         LDKReplyShortChannelIdsEnd 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         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
32956 }
32957
32958 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
32959         LDKThirtyTwoBytes chain_hash_arg_ref;
32960         CHECK(chain_hash_arg->arr_len == 32);
32961         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32962         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
32963         uint32_t ret_ref = 0;
32964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32967         ret_ref = (uintptr_t)ret_var.inner;
32968         if (ret_var.is_owned) {
32969                 ret_ref |= 1;
32970         }
32971         return ret_ref;
32972 }
32973
32974 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
32975         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
32976 uint32_t ret_ref = 0;
32977 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32978 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32979 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32980 ret_ref = (uintptr_t)ret_var.inner;
32981 if (ret_var.is_owned) {
32982         ret_ref |= 1;
32983 }
32984         return ret_ref;
32985 }
32986 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
32987         LDKReplyShortChannelIdsEnd arg_conv;
32988         arg_conv.inner = (void*)(arg & (~1));
32989         arg_conv.is_owned = false;
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32991         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
32992         return ret_conv;
32993 }
32994
32995 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
32996         LDKReplyShortChannelIdsEnd orig_conv;
32997         orig_conv.inner = (void*)(orig & (~1));
32998         orig_conv.is_owned = false;
32999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33000         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
33001         uint32_t ret_ref = 0;
33002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33005         ret_ref = (uintptr_t)ret_var.inner;
33006         if (ret_var.is_owned) {
33007                 ret_ref |= 1;
33008         }
33009         return ret_ref;
33010 }
33011
33012 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
33013         LDKGossipTimestampFilter this_obj_conv;
33014         this_obj_conv.inner = (void*)(this_obj & (~1));
33015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33017         GossipTimestampFilter_free(this_obj_conv);
33018 }
33019
33020 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
33021         LDKGossipTimestampFilter this_ptr_conv;
33022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33023         this_ptr_conv.is_owned = false;
33024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33025         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33026         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
33027         return ret_arr;
33028 }
33029
33030 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
33031         LDKGossipTimestampFilter this_ptr_conv;
33032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33033         this_ptr_conv.is_owned = false;
33034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33035         LDKThirtyTwoBytes val_ref;
33036         CHECK(val->arr_len == 32);
33037         memcpy(val_ref.data, val->elems, 32); FREE(val);
33038         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
33039 }
33040
33041 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
33042         LDKGossipTimestampFilter this_ptr_conv;
33043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33044         this_ptr_conv.is_owned = false;
33045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33046         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
33047         return ret_conv;
33048 }
33049
33050 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
33051         LDKGossipTimestampFilter this_ptr_conv;
33052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33053         this_ptr_conv.is_owned = false;
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33055         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
33056 }
33057
33058 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
33059         LDKGossipTimestampFilter this_ptr_conv;
33060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33061         this_ptr_conv.is_owned = false;
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33063         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
33064         return ret_conv;
33065 }
33066
33067 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
33068         LDKGossipTimestampFilter this_ptr_conv;
33069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33070         this_ptr_conv.is_owned = false;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33072         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
33073 }
33074
33075 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) {
33076         LDKThirtyTwoBytes chain_hash_arg_ref;
33077         CHECK(chain_hash_arg->arr_len == 32);
33078         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33079         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
33080         uint32_t ret_ref = 0;
33081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33084         ret_ref = (uintptr_t)ret_var.inner;
33085         if (ret_var.is_owned) {
33086                 ret_ref |= 1;
33087         }
33088         return ret_ref;
33089 }
33090
33091 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
33092         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
33093 uint32_t ret_ref = 0;
33094 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33095 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33096 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33097 ret_ref = (uintptr_t)ret_var.inner;
33098 if (ret_var.is_owned) {
33099         ret_ref |= 1;
33100 }
33101         return ret_ref;
33102 }
33103 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
33104         LDKGossipTimestampFilter arg_conv;
33105         arg_conv.inner = (void*)(arg & (~1));
33106         arg_conv.is_owned = false;
33107         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33108         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
33109         return ret_conv;
33110 }
33111
33112 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
33113         LDKGossipTimestampFilter orig_conv;
33114         orig_conv.inner = (void*)(orig & (~1));
33115         orig_conv.is_owned = false;
33116         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33117         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
33118         uint32_t ret_ref = 0;
33119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33122         ret_ref = (uintptr_t)ret_var.inner;
33123         if (ret_var.is_owned) {
33124                 ret_ref |= 1;
33125         }
33126         return ret_ref;
33127 }
33128
33129 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
33130         if ((this_ptr & 1) != 0) return;
33131         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33132         CHECK_ACCESS(this_ptr_ptr);
33133         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
33134         FREE((void*)this_ptr);
33135         ErrorAction_free(this_ptr_conv);
33136 }
33137
33138 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
33139         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33140         *ret_copy = ErrorAction_clone(arg);
33141 uint32_t ret_ref = (uintptr_t)ret_copy;
33142         return ret_ref;
33143 }
33144 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
33145         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
33146         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
33147         return ret_conv;
33148 }
33149
33150 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
33151         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
33152         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33153         *ret_copy = ErrorAction_clone(orig_conv);
33154         uint32_t ret_ref = (uintptr_t)ret_copy;
33155         return ret_ref;
33156 }
33157
33158 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
33159         LDKErrorMessage msg_conv;
33160         msg_conv.inner = (void*)(msg & (~1));
33161         msg_conv.is_owned = (msg & 1) || (msg == 0);
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33163         msg_conv = ErrorMessage_clone(&msg_conv);
33164         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33165         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
33166         uint32_t ret_ref = (uintptr_t)ret_copy;
33167         return ret_ref;
33168 }
33169
33170 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
33171         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33172         *ret_copy = ErrorAction_ignore_error();
33173         uint32_t ret_ref = (uintptr_t)ret_copy;
33174         return ret_ref;
33175 }
33176
33177 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
33178         LDKLevel a_conv = LDKLevel_from_js(a);
33179         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33180         *ret_copy = ErrorAction_ignore_and_log(a_conv);
33181         uint32_t ret_ref = (uintptr_t)ret_copy;
33182         return ret_ref;
33183 }
33184
33185 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
33186         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33187         *ret_copy = ErrorAction_ignore_duplicate_gossip();
33188         uint32_t ret_ref = (uintptr_t)ret_copy;
33189         return ret_ref;
33190 }
33191
33192 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
33193         LDKErrorMessage msg_conv;
33194         msg_conv.inner = (void*)(msg & (~1));
33195         msg_conv.is_owned = (msg & 1) || (msg == 0);
33196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33197         msg_conv = ErrorMessage_clone(&msg_conv);
33198         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33199         *ret_copy = ErrorAction_send_error_message(msg_conv);
33200         uint32_t ret_ref = (uintptr_t)ret_copy;
33201         return ret_ref;
33202 }
33203
33204 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
33205         LDKWarningMessage msg_conv;
33206         msg_conv.inner = (void*)(msg & (~1));
33207         msg_conv.is_owned = (msg & 1) || (msg == 0);
33208         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33209         msg_conv = WarningMessage_clone(&msg_conv);
33210         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
33211         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33212         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
33213         uint32_t ret_ref = (uintptr_t)ret_copy;
33214         return ret_ref;
33215 }
33216
33217 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
33218         LDKLightningError this_obj_conv;
33219         this_obj_conv.inner = (void*)(this_obj & (~1));
33220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33222         LightningError_free(this_obj_conv);
33223 }
33224
33225 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
33226         LDKLightningError this_ptr_conv;
33227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33228         this_ptr_conv.is_owned = false;
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33230         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
33231         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
33232         Str_free(ret_str);
33233         return ret_conv;
33234 }
33235
33236 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
33237         LDKLightningError this_ptr_conv;
33238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33239         this_ptr_conv.is_owned = false;
33240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33241         LDKStr val_conv = str_ref_to_owned_c(val);
33242         LightningError_set_err(&this_ptr_conv, val_conv);
33243 }
33244
33245 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
33246         LDKLightningError this_ptr_conv;
33247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33248         this_ptr_conv.is_owned = false;
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33250         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33251         *ret_copy = LightningError_get_action(&this_ptr_conv);
33252         uint32_t ret_ref = (uintptr_t)ret_copy;
33253         return ret_ref;
33254 }
33255
33256 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
33257         LDKLightningError this_ptr_conv;
33258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33259         this_ptr_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33261         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33262         CHECK_ACCESS(val_ptr);
33263         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
33264         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
33265         LightningError_set_action(&this_ptr_conv, val_conv);
33266 }
33267
33268 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
33269         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
33270         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
33271         CHECK_ACCESS(action_arg_ptr);
33272         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
33273         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
33274         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
33275         uint32_t ret_ref = 0;
33276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33279         ret_ref = (uintptr_t)ret_var.inner;
33280         if (ret_var.is_owned) {
33281                 ret_ref |= 1;
33282         }
33283         return ret_ref;
33284 }
33285
33286 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
33287         LDKLightningError ret_var = LightningError_clone(arg);
33288 uint32_t ret_ref = 0;
33289 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33290 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33291 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33292 ret_ref = (uintptr_t)ret_var.inner;
33293 if (ret_var.is_owned) {
33294         ret_ref |= 1;
33295 }
33296         return ret_ref;
33297 }
33298 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
33299         LDKLightningError arg_conv;
33300         arg_conv.inner = (void*)(arg & (~1));
33301         arg_conv.is_owned = false;
33302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33303         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
33304         return ret_conv;
33305 }
33306
33307 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
33308         LDKLightningError orig_conv;
33309         orig_conv.inner = (void*)(orig & (~1));
33310         orig_conv.is_owned = false;
33311         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33312         LDKLightningError ret_var = LightningError_clone(&orig_conv);
33313         uint32_t ret_ref = 0;
33314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33317         ret_ref = (uintptr_t)ret_var.inner;
33318         if (ret_var.is_owned) {
33319                 ret_ref |= 1;
33320         }
33321         return ret_ref;
33322 }
33323
33324 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
33325         LDKCommitmentUpdate this_obj_conv;
33326         this_obj_conv.inner = (void*)(this_obj & (~1));
33327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33329         CommitmentUpdate_free(this_obj_conv);
33330 }
33331
33332 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
33333         LDKCommitmentUpdate this_ptr_conv;
33334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33335         this_ptr_conv.is_owned = false;
33336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33337         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
33338         uint32_tArray ret_arr = NULL;
33339         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33340         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
33341         for (size_t p = 0; p < ret_var.datalen; p++) {
33342                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
33343                 uint32_t ret_conv_15_ref = 0;
33344                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33345                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
33347                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
33348                 if (ret_conv_15_var.is_owned) {
33349                         ret_conv_15_ref |= 1;
33350                 }
33351                 ret_arr_ptr[p] = ret_conv_15_ref;
33352         }
33353         
33354         FREE(ret_var.data);
33355         return ret_arr;
33356 }
33357
33358 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
33359         LDKCommitmentUpdate this_ptr_conv;
33360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33361         this_ptr_conv.is_owned = false;
33362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33363         LDKCVec_UpdateAddHTLCZ val_constr;
33364         val_constr.datalen = val->arr_len;
33365         if (val_constr.datalen > 0)
33366                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33367         else
33368                 val_constr.data = NULL;
33369         uint32_t* val_vals = val->elems;
33370         for (size_t p = 0; p < val_constr.datalen; p++) {
33371                 uint32_t val_conv_15 = val_vals[p];
33372                 LDKUpdateAddHTLC val_conv_15_conv;
33373                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
33374                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
33375                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
33376                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
33377                 val_constr.data[p] = val_conv_15_conv;
33378         }
33379         FREE(val);
33380         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
33381 }
33382
33383 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
33384         LDKCommitmentUpdate 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         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
33389         uint32_tArray ret_arr = NULL;
33390         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33391         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
33392         for (size_t t = 0; t < ret_var.datalen; t++) {
33393                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
33394                 uint32_t ret_conv_19_ref = 0;
33395                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33396                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33397                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
33398                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
33399                 if (ret_conv_19_var.is_owned) {
33400                         ret_conv_19_ref |= 1;
33401                 }
33402                 ret_arr_ptr[t] = ret_conv_19_ref;
33403         }
33404         
33405         FREE(ret_var.data);
33406         return ret_arr;
33407 }
33408
33409 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
33410         LDKCommitmentUpdate this_ptr_conv;
33411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33412         this_ptr_conv.is_owned = false;
33413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33414         LDKCVec_UpdateFulfillHTLCZ val_constr;
33415         val_constr.datalen = val->arr_len;
33416         if (val_constr.datalen > 0)
33417                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33418         else
33419                 val_constr.data = NULL;
33420         uint32_t* val_vals = val->elems;
33421         for (size_t t = 0; t < val_constr.datalen; t++) {
33422                 uint32_t val_conv_19 = val_vals[t];
33423                 LDKUpdateFulfillHTLC val_conv_19_conv;
33424                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
33425                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
33426                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
33427                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
33428                 val_constr.data[t] = val_conv_19_conv;
33429         }
33430         FREE(val);
33431         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
33432 }
33433
33434 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
33435         LDKCommitmentUpdate this_ptr_conv;
33436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33437         this_ptr_conv.is_owned = false;
33438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33439         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
33440         uint32_tArray ret_arr = NULL;
33441         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33442         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
33443         for (size_t q = 0; q < ret_var.datalen; q++) {
33444                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
33445                 uint32_t ret_conv_16_ref = 0;
33446                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33447                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33449                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
33450                 if (ret_conv_16_var.is_owned) {
33451                         ret_conv_16_ref |= 1;
33452                 }
33453                 ret_arr_ptr[q] = ret_conv_16_ref;
33454         }
33455         
33456         FREE(ret_var.data);
33457         return ret_arr;
33458 }
33459
33460 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
33461         LDKCommitmentUpdate this_ptr_conv;
33462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33463         this_ptr_conv.is_owned = false;
33464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33465         LDKCVec_UpdateFailHTLCZ val_constr;
33466         val_constr.datalen = val->arr_len;
33467         if (val_constr.datalen > 0)
33468                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33469         else
33470                 val_constr.data = NULL;
33471         uint32_t* val_vals = val->elems;
33472         for (size_t q = 0; q < val_constr.datalen; q++) {
33473                 uint32_t val_conv_16 = val_vals[q];
33474                 LDKUpdateFailHTLC val_conv_16_conv;
33475                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
33476                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
33477                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33478                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
33479                 val_constr.data[q] = val_conv_16_conv;
33480         }
33481         FREE(val);
33482         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
33483 }
33484
33485 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
33486         LDKCommitmentUpdate this_ptr_conv;
33487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33488         this_ptr_conv.is_owned = false;
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33490         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
33491         uint32_tArray ret_arr = NULL;
33492         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33493         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
33494         for (size_t z = 0; z < ret_var.datalen; z++) {
33495                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
33496                 uint32_t ret_conv_25_ref = 0;
33497                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33498                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33499                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
33500                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
33501                 if (ret_conv_25_var.is_owned) {
33502                         ret_conv_25_ref |= 1;
33503                 }
33504                 ret_arr_ptr[z] = ret_conv_25_ref;
33505         }
33506         
33507         FREE(ret_var.data);
33508         return ret_arr;
33509 }
33510
33511 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) {
33512         LDKCommitmentUpdate this_ptr_conv;
33513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33514         this_ptr_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33516         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
33517         val_constr.datalen = val->arr_len;
33518         if (val_constr.datalen > 0)
33519                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33520         else
33521                 val_constr.data = NULL;
33522         uint32_t* val_vals = val->elems;
33523         for (size_t z = 0; z < val_constr.datalen; z++) {
33524                 uint32_t val_conv_25 = val_vals[z];
33525                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
33526                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
33527                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
33528                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
33529                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
33530                 val_constr.data[z] = val_conv_25_conv;
33531         }
33532         FREE(val);
33533         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
33534 }
33535
33536 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
33537         LDKCommitmentUpdate this_ptr_conv;
33538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33539         this_ptr_conv.is_owned = false;
33540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33541         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
33542         uint32_t ret_ref = 0;
33543         if ((uintptr_t)ret_var.inner > 4096) {
33544                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33545                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33547                 ret_ref = (uintptr_t)ret_var.inner;
33548                 if (ret_var.is_owned) {
33549                         ret_ref |= 1;
33550                 }
33551         }
33552         return ret_ref;
33553 }
33554
33555 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
33556         LDKCommitmentUpdate this_ptr_conv;
33557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33558         this_ptr_conv.is_owned = false;
33559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33560         LDKUpdateFee val_conv;
33561         val_conv.inner = (void*)(val & (~1));
33562         val_conv.is_owned = (val & 1) || (val == 0);
33563         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33564         val_conv = UpdateFee_clone(&val_conv);
33565         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
33566 }
33567
33568 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
33569         LDKCommitmentUpdate this_ptr_conv;
33570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33571         this_ptr_conv.is_owned = false;
33572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33573         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
33574         uint32_t ret_ref = 0;
33575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33578         ret_ref = (uintptr_t)ret_var.inner;
33579         if (ret_var.is_owned) {
33580                 ret_ref |= 1;
33581         }
33582         return ret_ref;
33583 }
33584
33585 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
33586         LDKCommitmentUpdate this_ptr_conv;
33587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33588         this_ptr_conv.is_owned = false;
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33590         LDKCommitmentSigned val_conv;
33591         val_conv.inner = (void*)(val & (~1));
33592         val_conv.is_owned = (val & 1) || (val == 0);
33593         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33594         val_conv = CommitmentSigned_clone(&val_conv);
33595         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
33596 }
33597
33598 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) {
33599         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
33600         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
33601         if (update_add_htlcs_arg_constr.datalen > 0)
33602                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33603         else
33604                 update_add_htlcs_arg_constr.data = NULL;
33605         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
33606         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
33607                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
33608                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
33609                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
33610                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
33611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
33612                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
33613                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
33614         }
33615         FREE(update_add_htlcs_arg);
33616         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
33617         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
33618         if (update_fulfill_htlcs_arg_constr.datalen > 0)
33619                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33620         else
33621                 update_fulfill_htlcs_arg_constr.data = NULL;
33622         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
33623         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
33624                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
33625                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
33626                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
33627                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
33628                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
33629                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
33630                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
33631         }
33632         FREE(update_fulfill_htlcs_arg);
33633         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
33634         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
33635         if (update_fail_htlcs_arg_constr.datalen > 0)
33636                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33637         else
33638                 update_fail_htlcs_arg_constr.data = NULL;
33639         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
33640         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
33641                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
33642                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
33643                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
33644                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
33645                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
33646                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
33647                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
33648         }
33649         FREE(update_fail_htlcs_arg);
33650         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
33651         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
33652         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
33653                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33654         else
33655                 update_fail_malformed_htlcs_arg_constr.data = NULL;
33656         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
33657         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
33658                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
33659                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
33660                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
33661                 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);
33662                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
33663                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
33664                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
33665         }
33666         FREE(update_fail_malformed_htlcs_arg);
33667         LDKUpdateFee update_fee_arg_conv;
33668         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
33669         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
33670         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
33671         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
33672         LDKCommitmentSigned commitment_signed_arg_conv;
33673         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
33674         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
33675         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
33676         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
33677         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);
33678         uint32_t ret_ref = 0;
33679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33682         ret_ref = (uintptr_t)ret_var.inner;
33683         if (ret_var.is_owned) {
33684                 ret_ref |= 1;
33685         }
33686         return ret_ref;
33687 }
33688
33689 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
33690         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
33691 uint32_t ret_ref = 0;
33692 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33693 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33694 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33695 ret_ref = (uintptr_t)ret_var.inner;
33696 if (ret_var.is_owned) {
33697         ret_ref |= 1;
33698 }
33699         return ret_ref;
33700 }
33701 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
33702         LDKCommitmentUpdate arg_conv;
33703         arg_conv.inner = (void*)(arg & (~1));
33704         arg_conv.is_owned = false;
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33706         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33707         return ret_conv;
33708 }
33709
33710 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
33711         LDKCommitmentUpdate orig_conv;
33712         orig_conv.inner = (void*)(orig & (~1));
33713         orig_conv.is_owned = false;
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33715         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33716         uint32_t ret_ref = 0;
33717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33720         ret_ref = (uintptr_t)ret_var.inner;
33721         if (ret_var.is_owned) {
33722                 ret_ref |= 1;
33723         }
33724         return ret_ref;
33725 }
33726
33727 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
33728         if ((this_ptr & 1) != 0) return;
33729         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33730         CHECK_ACCESS(this_ptr_ptr);
33731         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33732         FREE((void*)this_ptr);
33733         ChannelMessageHandler_free(this_ptr_conv);
33734 }
33735
33736 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
33737         if ((this_ptr & 1) != 0) return;
33738         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33739         CHECK_ACCESS(this_ptr_ptr);
33740         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33741         FREE((void*)this_ptr);
33742         RoutingMessageHandler_free(this_ptr_conv);
33743 }
33744
33745 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
33746         LDKAcceptChannel obj_conv;
33747         obj_conv.inner = (void*)(obj & (~1));
33748         obj_conv.is_owned = false;
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33750         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33751         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33752         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33753         CVec_u8Z_free(ret_var);
33754         return ret_arr;
33755 }
33756
33757 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33758         LDKu8slice ser_ref;
33759         ser_ref.datalen = ser->arr_len;
33760         ser_ref.data = ser->elems;
33761         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33762         *ret_conv = AcceptChannel_read(ser_ref);
33763         FREE(ser);
33764         return (uint32_t)ret_conv;
33765 }
33766
33767 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
33768         LDKAnnouncementSignatures obj_conv;
33769         obj_conv.inner = (void*)(obj & (~1));
33770         obj_conv.is_owned = false;
33771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33772         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33773         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33774         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33775         CVec_u8Z_free(ret_var);
33776         return ret_arr;
33777 }
33778
33779 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33780         LDKu8slice ser_ref;
33781         ser_ref.datalen = ser->arr_len;
33782         ser_ref.data = ser->elems;
33783         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33784         *ret_conv = AnnouncementSignatures_read(ser_ref);
33785         FREE(ser);
33786         return (uint32_t)ret_conv;
33787 }
33788
33789 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
33790         LDKChannelReestablish obj_conv;
33791         obj_conv.inner = (void*)(obj & (~1));
33792         obj_conv.is_owned = false;
33793         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33794         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33795         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33796         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33797         CVec_u8Z_free(ret_var);
33798         return ret_arr;
33799 }
33800
33801 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33802         LDKu8slice ser_ref;
33803         ser_ref.datalen = ser->arr_len;
33804         ser_ref.data = ser->elems;
33805         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33806         *ret_conv = ChannelReestablish_read(ser_ref);
33807         FREE(ser);
33808         return (uint32_t)ret_conv;
33809 }
33810
33811 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
33812         LDKClosingSigned obj_conv;
33813         obj_conv.inner = (void*)(obj & (~1));
33814         obj_conv.is_owned = false;
33815         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33816         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33817         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33818         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33819         CVec_u8Z_free(ret_var);
33820         return ret_arr;
33821 }
33822
33823 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33824         LDKu8slice ser_ref;
33825         ser_ref.datalen = ser->arr_len;
33826         ser_ref.data = ser->elems;
33827         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33828         *ret_conv = ClosingSigned_read(ser_ref);
33829         FREE(ser);
33830         return (uint32_t)ret_conv;
33831 }
33832
33833 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
33834         LDKClosingSignedFeeRange obj_conv;
33835         obj_conv.inner = (void*)(obj & (~1));
33836         obj_conv.is_owned = false;
33837         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33838         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33839         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33840         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33841         CVec_u8Z_free(ret_var);
33842         return ret_arr;
33843 }
33844
33845 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33846         LDKu8slice ser_ref;
33847         ser_ref.datalen = ser->arr_len;
33848         ser_ref.data = ser->elems;
33849         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33850         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33851         FREE(ser);
33852         return (uint32_t)ret_conv;
33853 }
33854
33855 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
33856         LDKCommitmentSigned obj_conv;
33857         obj_conv.inner = (void*)(obj & (~1));
33858         obj_conv.is_owned = false;
33859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33860         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33861         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33862         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33863         CVec_u8Z_free(ret_var);
33864         return ret_arr;
33865 }
33866
33867 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33868         LDKu8slice ser_ref;
33869         ser_ref.datalen = ser->arr_len;
33870         ser_ref.data = ser->elems;
33871         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33872         *ret_conv = CommitmentSigned_read(ser_ref);
33873         FREE(ser);
33874         return (uint32_t)ret_conv;
33875 }
33876
33877 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
33878         LDKFundingCreated obj_conv;
33879         obj_conv.inner = (void*)(obj & (~1));
33880         obj_conv.is_owned = false;
33881         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33882         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33883         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33884         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33885         CVec_u8Z_free(ret_var);
33886         return ret_arr;
33887 }
33888
33889 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33890         LDKu8slice ser_ref;
33891         ser_ref.datalen = ser->arr_len;
33892         ser_ref.data = ser->elems;
33893         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
33894         *ret_conv = FundingCreated_read(ser_ref);
33895         FREE(ser);
33896         return (uint32_t)ret_conv;
33897 }
33898
33899 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
33900         LDKFundingSigned obj_conv;
33901         obj_conv.inner = (void*)(obj & (~1));
33902         obj_conv.is_owned = false;
33903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33904         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
33905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33907         CVec_u8Z_free(ret_var);
33908         return ret_arr;
33909 }
33910
33911 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
33912         LDKu8slice ser_ref;
33913         ser_ref.datalen = ser->arr_len;
33914         ser_ref.data = ser->elems;
33915         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
33916         *ret_conv = FundingSigned_read(ser_ref);
33917         FREE(ser);
33918         return (uint32_t)ret_conv;
33919 }
33920
33921 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
33922         LDKChannelReady obj_conv;
33923         obj_conv.inner = (void*)(obj & (~1));
33924         obj_conv.is_owned = false;
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33926         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
33927         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33928         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33929         CVec_u8Z_free(ret_var);
33930         return ret_arr;
33931 }
33932
33933 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
33934         LDKu8slice ser_ref;
33935         ser_ref.datalen = ser->arr_len;
33936         ser_ref.data = ser->elems;
33937         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
33938         *ret_conv = ChannelReady_read(ser_ref);
33939         FREE(ser);
33940         return (uint32_t)ret_conv;
33941 }
33942
33943 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
33944         LDKInit obj_conv;
33945         obj_conv.inner = (void*)(obj & (~1));
33946         obj_conv.is_owned = false;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33948         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
33949         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33950         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33951         CVec_u8Z_free(ret_var);
33952         return ret_arr;
33953 }
33954
33955 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
33956         LDKu8slice ser_ref;
33957         ser_ref.datalen = ser->arr_len;
33958         ser_ref.data = ser->elems;
33959         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
33960         *ret_conv = Init_read(ser_ref);
33961         FREE(ser);
33962         return (uint32_t)ret_conv;
33963 }
33964
33965 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
33966         LDKOpenChannel obj_conv;
33967         obj_conv.inner = (void*)(obj & (~1));
33968         obj_conv.is_owned = false;
33969         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33970         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
33971         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33972         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33973         CVec_u8Z_free(ret_var);
33974         return ret_arr;
33975 }
33976
33977 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
33978         LDKu8slice ser_ref;
33979         ser_ref.datalen = ser->arr_len;
33980         ser_ref.data = ser->elems;
33981         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
33982         *ret_conv = OpenChannel_read(ser_ref);
33983         FREE(ser);
33984         return (uint32_t)ret_conv;
33985 }
33986
33987 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
33988         LDKRevokeAndACK obj_conv;
33989         obj_conv.inner = (void*)(obj & (~1));
33990         obj_conv.is_owned = false;
33991         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33992         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
33993         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33994         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33995         CVec_u8Z_free(ret_var);
33996         return ret_arr;
33997 }
33998
33999 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
34000         LDKu8slice ser_ref;
34001         ser_ref.datalen = ser->arr_len;
34002         ser_ref.data = ser->elems;
34003         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
34004         *ret_conv = RevokeAndACK_read(ser_ref);
34005         FREE(ser);
34006         return (uint32_t)ret_conv;
34007 }
34008
34009 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
34010         LDKShutdown obj_conv;
34011         obj_conv.inner = (void*)(obj & (~1));
34012         obj_conv.is_owned = false;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34014         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
34015         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34016         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34017         CVec_u8Z_free(ret_var);
34018         return ret_arr;
34019 }
34020
34021 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
34022         LDKu8slice ser_ref;
34023         ser_ref.datalen = ser->arr_len;
34024         ser_ref.data = ser->elems;
34025         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
34026         *ret_conv = Shutdown_read(ser_ref);
34027         FREE(ser);
34028         return (uint32_t)ret_conv;
34029 }
34030
34031 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
34032         LDKUpdateFailHTLC obj_conv;
34033         obj_conv.inner = (void*)(obj & (~1));
34034         obj_conv.is_owned = false;
34035         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34036         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
34037         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34038         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34039         CVec_u8Z_free(ret_var);
34040         return ret_arr;
34041 }
34042
34043 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
34044         LDKu8slice ser_ref;
34045         ser_ref.datalen = ser->arr_len;
34046         ser_ref.data = ser->elems;
34047         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
34048         *ret_conv = UpdateFailHTLC_read(ser_ref);
34049         FREE(ser);
34050         return (uint32_t)ret_conv;
34051 }
34052
34053 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
34054         LDKUpdateFailMalformedHTLC obj_conv;
34055         obj_conv.inner = (void*)(obj & (~1));
34056         obj_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34058         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
34059         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34060         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34061         CVec_u8Z_free(ret_var);
34062         return ret_arr;
34063 }
34064
34065 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
34066         LDKu8slice ser_ref;
34067         ser_ref.datalen = ser->arr_len;
34068         ser_ref.data = ser->elems;
34069         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
34070         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
34071         FREE(ser);
34072         return (uint32_t)ret_conv;
34073 }
34074
34075 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
34076         LDKUpdateFee obj_conv;
34077         obj_conv.inner = (void*)(obj & (~1));
34078         obj_conv.is_owned = false;
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34080         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_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         CVec_u8Z_free(ret_var);
34084         return ret_arr;
34085 }
34086
34087 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
34088         LDKu8slice ser_ref;
34089         ser_ref.datalen = ser->arr_len;
34090         ser_ref.data = ser->elems;
34091         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
34092         *ret_conv = UpdateFee_read(ser_ref);
34093         FREE(ser);
34094         return (uint32_t)ret_conv;
34095 }
34096
34097 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
34098         LDKUpdateFulfillHTLC obj_conv;
34099         obj_conv.inner = (void*)(obj & (~1));
34100         obj_conv.is_owned = false;
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34102         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
34103         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34104         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34105         CVec_u8Z_free(ret_var);
34106         return ret_arr;
34107 }
34108
34109 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
34110         LDKu8slice ser_ref;
34111         ser_ref.datalen = ser->arr_len;
34112         ser_ref.data = ser->elems;
34113         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
34114         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
34115         FREE(ser);
34116         return (uint32_t)ret_conv;
34117 }
34118
34119 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
34120         LDKUpdateAddHTLC obj_conv;
34121         obj_conv.inner = (void*)(obj & (~1));
34122         obj_conv.is_owned = false;
34123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34124         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
34125         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34126         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34127         CVec_u8Z_free(ret_var);
34128         return ret_arr;
34129 }
34130
34131 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
34132         LDKu8slice ser_ref;
34133         ser_ref.datalen = ser->arr_len;
34134         ser_ref.data = ser->elems;
34135         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
34136         *ret_conv = UpdateAddHTLC_read(ser_ref);
34137         FREE(ser);
34138         return (uint32_t)ret_conv;
34139 }
34140
34141 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
34142         LDKPing obj_conv;
34143         obj_conv.inner = (void*)(obj & (~1));
34144         obj_conv.is_owned = false;
34145         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34146         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
34147         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34148         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34149         CVec_u8Z_free(ret_var);
34150         return ret_arr;
34151 }
34152
34153 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
34154         LDKu8slice ser_ref;
34155         ser_ref.datalen = ser->arr_len;
34156         ser_ref.data = ser->elems;
34157         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
34158         *ret_conv = Ping_read(ser_ref);
34159         FREE(ser);
34160         return (uint32_t)ret_conv;
34161 }
34162
34163 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
34164         LDKPong obj_conv;
34165         obj_conv.inner = (void*)(obj & (~1));
34166         obj_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34168         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
34169         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34170         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34171         CVec_u8Z_free(ret_var);
34172         return ret_arr;
34173 }
34174
34175 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
34176         LDKu8slice ser_ref;
34177         ser_ref.datalen = ser->arr_len;
34178         ser_ref.data = ser->elems;
34179         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
34180         *ret_conv = Pong_read(ser_ref);
34181         FREE(ser);
34182         return (uint32_t)ret_conv;
34183 }
34184
34185 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
34186         LDKUnsignedChannelAnnouncement obj_conv;
34187         obj_conv.inner = (void*)(obj & (~1));
34188         obj_conv.is_owned = false;
34189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34190         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
34191         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34192         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34193         CVec_u8Z_free(ret_var);
34194         return ret_arr;
34195 }
34196
34197 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
34198         LDKu8slice ser_ref;
34199         ser_ref.datalen = ser->arr_len;
34200         ser_ref.data = ser->elems;
34201         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
34202         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
34203         FREE(ser);
34204         return (uint32_t)ret_conv;
34205 }
34206
34207 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
34208         LDKChannelAnnouncement obj_conv;
34209         obj_conv.inner = (void*)(obj & (~1));
34210         obj_conv.is_owned = false;
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34212         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
34213         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34214         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34215         CVec_u8Z_free(ret_var);
34216         return ret_arr;
34217 }
34218
34219 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
34220         LDKu8slice ser_ref;
34221         ser_ref.datalen = ser->arr_len;
34222         ser_ref.data = ser->elems;
34223         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
34224         *ret_conv = ChannelAnnouncement_read(ser_ref);
34225         FREE(ser);
34226         return (uint32_t)ret_conv;
34227 }
34228
34229 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
34230         LDKUnsignedChannelUpdate obj_conv;
34231         obj_conv.inner = (void*)(obj & (~1));
34232         obj_conv.is_owned = false;
34233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34234         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
34235         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34236         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34237         CVec_u8Z_free(ret_var);
34238         return ret_arr;
34239 }
34240
34241 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
34242         LDKu8slice ser_ref;
34243         ser_ref.datalen = ser->arr_len;
34244         ser_ref.data = ser->elems;
34245         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
34246         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
34247         FREE(ser);
34248         return (uint32_t)ret_conv;
34249 }
34250
34251 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
34252         LDKChannelUpdate obj_conv;
34253         obj_conv.inner = (void*)(obj & (~1));
34254         obj_conv.is_owned = false;
34255         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34256         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
34257         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34258         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34259         CVec_u8Z_free(ret_var);
34260         return ret_arr;
34261 }
34262
34263 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
34264         LDKu8slice ser_ref;
34265         ser_ref.datalen = ser->arr_len;
34266         ser_ref.data = ser->elems;
34267         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
34268         *ret_conv = ChannelUpdate_read(ser_ref);
34269         FREE(ser);
34270         return (uint32_t)ret_conv;
34271 }
34272
34273 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
34274         LDKErrorMessage obj_conv;
34275         obj_conv.inner = (void*)(obj & (~1));
34276         obj_conv.is_owned = false;
34277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34278         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
34279         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34280         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34281         CVec_u8Z_free(ret_var);
34282         return ret_arr;
34283 }
34284
34285 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
34286         LDKu8slice ser_ref;
34287         ser_ref.datalen = ser->arr_len;
34288         ser_ref.data = ser->elems;
34289         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
34290         *ret_conv = ErrorMessage_read(ser_ref);
34291         FREE(ser);
34292         return (uint32_t)ret_conv;
34293 }
34294
34295 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
34296         LDKWarningMessage obj_conv;
34297         obj_conv.inner = (void*)(obj & (~1));
34298         obj_conv.is_owned = false;
34299         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34300         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
34301         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34302         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34303         CVec_u8Z_free(ret_var);
34304         return ret_arr;
34305 }
34306
34307 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
34308         LDKu8slice ser_ref;
34309         ser_ref.datalen = ser->arr_len;
34310         ser_ref.data = ser->elems;
34311         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
34312         *ret_conv = WarningMessage_read(ser_ref);
34313         FREE(ser);
34314         return (uint32_t)ret_conv;
34315 }
34316
34317 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
34318         LDKUnsignedNodeAnnouncement obj_conv;
34319         obj_conv.inner = (void*)(obj & (~1));
34320         obj_conv.is_owned = false;
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34322         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
34323         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34324         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34325         CVec_u8Z_free(ret_var);
34326         return ret_arr;
34327 }
34328
34329 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
34330         LDKu8slice ser_ref;
34331         ser_ref.datalen = ser->arr_len;
34332         ser_ref.data = ser->elems;
34333         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
34334         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
34335         FREE(ser);
34336         return (uint32_t)ret_conv;
34337 }
34338
34339 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
34340         LDKNodeAnnouncement obj_conv;
34341         obj_conv.inner = (void*)(obj & (~1));
34342         obj_conv.is_owned = false;
34343         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34344         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
34345         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34346         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34347         CVec_u8Z_free(ret_var);
34348         return ret_arr;
34349 }
34350
34351 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
34352         LDKu8slice ser_ref;
34353         ser_ref.datalen = ser->arr_len;
34354         ser_ref.data = ser->elems;
34355         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
34356         *ret_conv = NodeAnnouncement_read(ser_ref);
34357         FREE(ser);
34358         return (uint32_t)ret_conv;
34359 }
34360
34361 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
34362         LDKu8slice ser_ref;
34363         ser_ref.datalen = ser->arr_len;
34364         ser_ref.data = ser->elems;
34365         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
34366         *ret_conv = QueryShortChannelIds_read(ser_ref);
34367         FREE(ser);
34368         return (uint32_t)ret_conv;
34369 }
34370
34371 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
34372         LDKQueryShortChannelIds obj_conv;
34373         obj_conv.inner = (void*)(obj & (~1));
34374         obj_conv.is_owned = false;
34375         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34376         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
34377         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34378         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34379         CVec_u8Z_free(ret_var);
34380         return ret_arr;
34381 }
34382
34383 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
34384         LDKReplyShortChannelIdsEnd obj_conv;
34385         obj_conv.inner = (void*)(obj & (~1));
34386         obj_conv.is_owned = false;
34387         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34388         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
34389         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34390         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34391         CVec_u8Z_free(ret_var);
34392         return ret_arr;
34393 }
34394
34395 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
34396         LDKu8slice ser_ref;
34397         ser_ref.datalen = ser->arr_len;
34398         ser_ref.data = ser->elems;
34399         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
34400         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
34401         FREE(ser);
34402         return (uint32_t)ret_conv;
34403 }
34404
34405 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
34406         LDKQueryChannelRange this_arg_conv;
34407         this_arg_conv.inner = (void*)(this_arg & (~1));
34408         this_arg_conv.is_owned = false;
34409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34410         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
34411         return ret_conv;
34412 }
34413
34414 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
34415         LDKQueryChannelRange obj_conv;
34416         obj_conv.inner = (void*)(obj & (~1));
34417         obj_conv.is_owned = false;
34418         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34419         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
34420         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34421         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34422         CVec_u8Z_free(ret_var);
34423         return ret_arr;
34424 }
34425
34426 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
34427         LDKu8slice ser_ref;
34428         ser_ref.datalen = ser->arr_len;
34429         ser_ref.data = ser->elems;
34430         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
34431         *ret_conv = QueryChannelRange_read(ser_ref);
34432         FREE(ser);
34433         return (uint32_t)ret_conv;
34434 }
34435
34436 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
34437         LDKu8slice ser_ref;
34438         ser_ref.datalen = ser->arr_len;
34439         ser_ref.data = ser->elems;
34440         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
34441         *ret_conv = ReplyChannelRange_read(ser_ref);
34442         FREE(ser);
34443         return (uint32_t)ret_conv;
34444 }
34445
34446 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
34447         LDKReplyChannelRange obj_conv;
34448         obj_conv.inner = (void*)(obj & (~1));
34449         obj_conv.is_owned = false;
34450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34451         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
34452         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34453         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34454         CVec_u8Z_free(ret_var);
34455         return ret_arr;
34456 }
34457
34458 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
34459         LDKGossipTimestampFilter obj_conv;
34460         obj_conv.inner = (void*)(obj & (~1));
34461         obj_conv.is_owned = false;
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34463         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
34464         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34465         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34466         CVec_u8Z_free(ret_var);
34467         return ret_arr;
34468 }
34469
34470 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
34471         LDKu8slice ser_ref;
34472         ser_ref.datalen = ser->arr_len;
34473         ser_ref.data = ser->elems;
34474         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
34475         *ret_conv = GossipTimestampFilter_read(ser_ref);
34476         FREE(ser);
34477         return (uint32_t)ret_conv;
34478 }
34479
34480 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
34481         if ((this_ptr & 1) != 0) return;
34482         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34483         CHECK_ACCESS(this_ptr_ptr);
34484         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
34485         FREE((void*)this_ptr);
34486         CustomMessageHandler_free(this_ptr_conv);
34487 }
34488
34489 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
34490         LDKIgnoringMessageHandler this_obj_conv;
34491         this_obj_conv.inner = (void*)(this_obj & (~1));
34492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34494         IgnoringMessageHandler_free(this_obj_conv);
34495 }
34496
34497 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
34498         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
34499         uint32_t ret_ref = 0;
34500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34503         ret_ref = (uintptr_t)ret_var.inner;
34504         if (ret_var.is_owned) {
34505                 ret_ref |= 1;
34506         }
34507         return ret_ref;
34508 }
34509
34510 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34511         LDKIgnoringMessageHandler this_arg_conv;
34512         this_arg_conv.inner = (void*)(this_arg & (~1));
34513         this_arg_conv.is_owned = false;
34514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34515         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34516         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34517         return (uint32_t)ret_ret;
34518 }
34519
34520 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
34521         LDKIgnoringMessageHandler this_arg_conv;
34522         this_arg_conv.inner = (void*)(this_arg & (~1));
34523         this_arg_conv.is_owned = false;
34524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34525         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34526         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
34527         return (uint32_t)ret_ret;
34528 }
34529
34530 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
34531         LDKIgnoringMessageHandler this_arg_conv;
34532         this_arg_conv.inner = (void*)(this_arg & (~1));
34533         this_arg_conv.is_owned = false;
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34535         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
34536         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
34537         return (uint32_t)ret_ret;
34538 }
34539
34540 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
34541         LDKIgnoringMessageHandler this_arg_conv;
34542         this_arg_conv.inner = (void*)(this_arg & (~1));
34543         this_arg_conv.is_owned = false;
34544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34545         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
34546         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
34547         return (uint32_t)ret_ret;
34548 }
34549
34550 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
34551         LDKErroringMessageHandler this_obj_conv;
34552         this_obj_conv.inner = (void*)(this_obj & (~1));
34553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34555         ErroringMessageHandler_free(this_obj_conv);
34556 }
34557
34558 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
34559         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
34560         uint32_t ret_ref = 0;
34561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34564         ret_ref = (uintptr_t)ret_var.inner;
34565         if (ret_var.is_owned) {
34566                 ret_ref |= 1;
34567         }
34568         return ret_ref;
34569 }
34570
34571 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34572         LDKErroringMessageHandler this_arg_conv;
34573         this_arg_conv.inner = (void*)(this_arg & (~1));
34574         this_arg_conv.is_owned = false;
34575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34576         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34577         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34578         return (uint32_t)ret_ret;
34579 }
34580
34581 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
34582         LDKErroringMessageHandler this_arg_conv;
34583         this_arg_conv.inner = (void*)(this_arg & (~1));
34584         this_arg_conv.is_owned = false;
34585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34586         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34587         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
34588         return (uint32_t)ret_ret;
34589 }
34590
34591 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
34592         LDKMessageHandler this_obj_conv;
34593         this_obj_conv.inner = (void*)(this_obj & (~1));
34594         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34596         MessageHandler_free(this_obj_conv);
34597 }
34598
34599 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
34600         LDKMessageHandler this_ptr_conv;
34601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34602         this_ptr_conv.is_owned = false;
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34604         // WARNING: This object doesn't live past this scope, needs clone!
34605         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
34606         return ret_ret;
34607 }
34608
34609 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
34610         LDKMessageHandler this_ptr_conv;
34611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34612         this_ptr_conv.is_owned = false;
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34614         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34615         CHECK_ACCESS(val_ptr);
34616         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
34617         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
34618                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34619                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
34620         }
34621         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
34622 }
34623
34624 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
34625         LDKMessageHandler this_ptr_conv;
34626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34627         this_ptr_conv.is_owned = false;
34628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34629         // WARNING: This object doesn't live past this scope, needs clone!
34630         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
34631         return ret_ret;
34632 }
34633
34634 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
34635         LDKMessageHandler this_ptr_conv;
34636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34637         this_ptr_conv.is_owned = false;
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34639         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34640         CHECK_ACCESS(val_ptr);
34641         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
34642         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34643                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34644                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
34645         }
34646         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
34647 }
34648
34649 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
34650         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
34651         CHECK_ACCESS(chan_handler_arg_ptr);
34652         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
34653         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
34654                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34655                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
34656         }
34657         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
34658         CHECK_ACCESS(route_handler_arg_ptr);
34659         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
34660         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34662                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
34663         }
34664         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
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 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
34677         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34678         *ret_ret = SocketDescriptor_clone(arg);
34679         return (uint32_t)ret_ret;
34680 }
34681 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
34682         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
34683         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
34684         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
34685         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
34686         return ret_conv;
34687 }
34688
34689 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
34690         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
34691         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
34692         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
34693         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34694         *ret_ret = SocketDescriptor_clone(orig_conv);
34695         return (uint32_t)ret_ret;
34696 }
34697
34698 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
34699         if ((this_ptr & 1) != 0) return;
34700         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34701         CHECK_ACCESS(this_ptr_ptr);
34702         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34703         FREE((void*)this_ptr);
34704         SocketDescriptor_free(this_ptr_conv);
34705 }
34706
34707 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
34708         LDKPeerHandleError this_obj_conv;
34709         this_obj_conv.inner = (void*)(this_obj & (~1));
34710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34712         PeerHandleError_free(this_obj_conv);
34713 }
34714
34715 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
34716         LDKPeerHandleError this_ptr_conv;
34717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34718         this_ptr_conv.is_owned = false;
34719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34720         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34721         return ret_conv;
34722 }
34723
34724 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
34725         LDKPeerHandleError this_ptr_conv;
34726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34727         this_ptr_conv.is_owned = false;
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34729         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34730 }
34731
34732 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34733         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34734         uint32_t ret_ref = 0;
34735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34738         ret_ref = (uintptr_t)ret_var.inner;
34739         if (ret_var.is_owned) {
34740                 ret_ref |= 1;
34741         }
34742         return ret_ref;
34743 }
34744
34745 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34746         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34747 uint32_t ret_ref = 0;
34748 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34749 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34750 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34751 ret_ref = (uintptr_t)ret_var.inner;
34752 if (ret_var.is_owned) {
34753         ret_ref |= 1;
34754 }
34755         return ret_ref;
34756 }
34757 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
34758         LDKPeerHandleError arg_conv;
34759         arg_conv.inner = (void*)(arg & (~1));
34760         arg_conv.is_owned = false;
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34762         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34763         return ret_conv;
34764 }
34765
34766 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
34767         LDKPeerHandleError orig_conv;
34768         orig_conv.inner = (void*)(orig & (~1));
34769         orig_conv.is_owned = false;
34770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34771         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34772         uint32_t ret_ref = 0;
34773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34776         ret_ref = (uintptr_t)ret_var.inner;
34777         if (ret_var.is_owned) {
34778                 ret_ref |= 1;
34779         }
34780         return ret_ref;
34781 }
34782
34783 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
34784         LDKPeerManager this_obj_conv;
34785         this_obj_conv.inner = (void*)(this_obj & (~1));
34786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34788         PeerManager_free(this_obj_conv);
34789 }
34790
34791 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) {
34792         LDKMessageHandler message_handler_conv;
34793         message_handler_conv.inner = (void*)(message_handler & (~1));
34794         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
34795         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34796         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34797         LDKSecretKey our_node_secret_ref;
34798         CHECK(our_node_secret->arr_len == 32);
34799         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34800         unsigned char ephemeral_random_data_arr[32];
34801         CHECK(ephemeral_random_data->arr_len == 32);
34802         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34803         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34804         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34805         CHECK_ACCESS(logger_ptr);
34806         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34807         if (logger_conv.free == LDKLogger_JCalls_free) {
34808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34809                 LDKLogger_JCalls_cloned(&logger_conv);
34810         }
34811         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
34812         CHECK_ACCESS(custom_message_handler_ptr);
34813         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34814         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34815                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34816                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34817         }
34818         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34819         uint32_t ret_ref = 0;
34820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34823         ret_ref = (uintptr_t)ret_var.inner;
34824         if (ret_var.is_owned) {
34825                 ret_ref |= 1;
34826         }
34827         return ret_ref;
34828 }
34829
34830 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
34831         LDKPeerManager this_arg_conv;
34832         this_arg_conv.inner = (void*)(this_arg & (~1));
34833         this_arg_conv.is_owned = false;
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34835         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34836         ptrArray ret_arr = NULL;
34837         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34838         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
34839         for (size_t m = 0; m < ret_var.datalen; m++) {
34840                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34841                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34842                 ret_arr_ptr[m] = ret_conv_12_arr;
34843         }
34844         
34845         FREE(ret_var.data);
34846         return ret_arr;
34847 }
34848
34849 uint32_t  __attribute__((export_name("TS_PeerManager_new_outbound_connection"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor, uint32_t remote_network_address) {
34850         LDKPeerManager this_arg_conv;
34851         this_arg_conv.inner = (void*)(this_arg & (~1));
34852         this_arg_conv.is_owned = false;
34853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34854         LDKPublicKey their_node_id_ref;
34855         CHECK(their_node_id->arr_len == 33);
34856         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34857         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34858         CHECK_ACCESS(descriptor_ptr);
34859         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34860         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34862                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34863         }
34864         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34865         CHECK_ACCESS(remote_network_address_ptr);
34866         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34867         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34868         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34869         return (uint32_t)ret_conv;
34870 }
34871
34872 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor, uint32_t remote_network_address) {
34873         LDKPeerManager this_arg_conv;
34874         this_arg_conv.inner = (void*)(this_arg & (~1));
34875         this_arg_conv.is_owned = false;
34876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34877         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34878         CHECK_ACCESS(descriptor_ptr);
34879         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34880         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34881                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34882                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34883         }
34884         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34885         CHECK_ACCESS(remote_network_address_ptr);
34886         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34887         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34888         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34889         return (uint32_t)ret_conv;
34890 }
34891
34892 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
34893         LDKPeerManager this_arg_conv;
34894         this_arg_conv.inner = (void*)(this_arg & (~1));
34895         this_arg_conv.is_owned = false;
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34897         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34898         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34899         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34900         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34901         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
34902         return (uint32_t)ret_conv;
34903 }
34904
34905 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
34906         LDKPeerManager this_arg_conv;
34907         this_arg_conv.inner = (void*)(this_arg & (~1));
34908         this_arg_conv.is_owned = false;
34909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34910         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
34911         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
34912         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
34913         LDKu8slice data_ref;
34914         data_ref.datalen = data->arr_len;
34915         data_ref.data = data->elems;
34916         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
34917         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
34918         FREE(data);
34919         return (uint32_t)ret_conv;
34920 }
34921
34922 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
34923         LDKPeerManager this_arg_conv;
34924         this_arg_conv.inner = (void*)(this_arg & (~1));
34925         this_arg_conv.is_owned = false;
34926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34927         PeerManager_process_events(&this_arg_conv);
34928 }
34929
34930 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
34931         LDKPeerManager this_arg_conv;
34932         this_arg_conv.inner = (void*)(this_arg & (~1));
34933         this_arg_conv.is_owned = false;
34934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34935         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34936         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34937         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34938         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
34939 }
34940
34941 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) {
34942         LDKPeerManager this_arg_conv;
34943         this_arg_conv.inner = (void*)(this_arg & (~1));
34944         this_arg_conv.is_owned = false;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34946         LDKPublicKey node_id_ref;
34947         CHECK(node_id->arr_len == 33);
34948         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
34949         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
34950 }
34951
34952 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
34953         LDKPeerManager this_arg_conv;
34954         this_arg_conv.inner = (void*)(this_arg & (~1));
34955         this_arg_conv.is_owned = false;
34956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34957         PeerManager_disconnect_all_peers(&this_arg_conv);
34958 }
34959
34960 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
34961         LDKPeerManager this_arg_conv;
34962         this_arg_conv.inner = (void*)(this_arg & (~1));
34963         this_arg_conv.is_owned = false;
34964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34965         PeerManager_timer_tick_occurred(&this_arg_conv);
34966 }
34967
34968 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
34969         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
34970         return ret_conv;
34971 }
34972
34973 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
34974         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
34975         return ret_conv;
34976 }
34977
34978 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
34979         unsigned char commitment_seed_arr[32];
34980         CHECK(commitment_seed->arr_len == 32);
34981         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
34982         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
34983         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34984         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
34985         return ret_arr;
34986 }
34987
34988 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) {
34989         LDKCVec_u8Z to_holder_script_ref;
34990         to_holder_script_ref.datalen = to_holder_script->arr_len;
34991         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34992         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34993         LDKCVec_u8Z to_counterparty_script_ref;
34994         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34995         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34996         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34997         LDKOutPoint funding_outpoint_conv;
34998         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34999         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35000         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35001         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35002         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);
35003         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35004         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35005         Transaction_free(ret_var);
35006         return ret_arr;
35007 }
35008
35009 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
35010         LDKCounterpartyCommitmentSecrets this_obj_conv;
35011         this_obj_conv.inner = (void*)(this_obj & (~1));
35012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35014         CounterpartyCommitmentSecrets_free(this_obj_conv);
35015 }
35016
35017 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
35018         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
35019 uint32_t ret_ref = 0;
35020 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35021 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35023 ret_ref = (uintptr_t)ret_var.inner;
35024 if (ret_var.is_owned) {
35025         ret_ref |= 1;
35026 }
35027         return ret_ref;
35028 }
35029 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
35030         LDKCounterpartyCommitmentSecrets arg_conv;
35031         arg_conv.inner = (void*)(arg & (~1));
35032         arg_conv.is_owned = false;
35033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35034         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
35035         return ret_conv;
35036 }
35037
35038 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
35039         LDKCounterpartyCommitmentSecrets orig_conv;
35040         orig_conv.inner = (void*)(orig & (~1));
35041         orig_conv.is_owned = false;
35042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35043         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
35044         uint32_t ret_ref = 0;
35045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35048         ret_ref = (uintptr_t)ret_var.inner;
35049         if (ret_var.is_owned) {
35050                 ret_ref |= 1;
35051         }
35052         return ret_ref;
35053 }
35054
35055 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
35056         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
35057         uint32_t ret_ref = 0;
35058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35061         ret_ref = (uintptr_t)ret_var.inner;
35062         if (ret_var.is_owned) {
35063                 ret_ref |= 1;
35064         }
35065         return ret_ref;
35066 }
35067
35068 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
35069         LDKCounterpartyCommitmentSecrets this_arg_conv;
35070         this_arg_conv.inner = (void*)(this_arg & (~1));
35071         this_arg_conv.is_owned = false;
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35073         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
35074         return ret_conv;
35075 }
35076
35077 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
35078         LDKCounterpartyCommitmentSecrets this_arg_conv;
35079         this_arg_conv.inner = (void*)(this_arg & (~1));
35080         this_arg_conv.is_owned = false;
35081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35082         LDKThirtyTwoBytes secret_ref;
35083         CHECK(secret->arr_len == 32);
35084         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
35085         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
35086         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
35087         return (uint32_t)ret_conv;
35088 }
35089
35090 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
35091         LDKCounterpartyCommitmentSecrets this_arg_conv;
35092         this_arg_conv.inner = (void*)(this_arg & (~1));
35093         this_arg_conv.is_owned = false;
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35095         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35096         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
35097         return ret_arr;
35098 }
35099
35100 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
35101         LDKCounterpartyCommitmentSecrets obj_conv;
35102         obj_conv.inner = (void*)(obj & (~1));
35103         obj_conv.is_owned = false;
35104         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35105         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
35106         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35107         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35108         CVec_u8Z_free(ret_var);
35109         return ret_arr;
35110 }
35111
35112 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
35113         LDKu8slice ser_ref;
35114         ser_ref.datalen = ser->arr_len;
35115         ser_ref.data = ser->elems;
35116         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
35117         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
35118         FREE(ser);
35119         return (uint32_t)ret_conv;
35120 }
35121
35122 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
35123         LDKPublicKey per_commitment_point_ref;
35124         CHECK(per_commitment_point->arr_len == 33);
35125         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35126         unsigned char base_secret_arr[32];
35127         CHECK(base_secret->arr_len == 32);
35128         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
35129         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
35130         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35131         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
35132         return (uint32_t)ret_conv;
35133 }
35134
35135 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
35136         LDKPublicKey per_commitment_point_ref;
35137         CHECK(per_commitment_point->arr_len == 33);
35138         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35139         LDKPublicKey base_point_ref;
35140         CHECK(base_point->arr_len == 33);
35141         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
35142         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35143         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
35144         return (uint32_t)ret_conv;
35145 }
35146
35147 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) {
35148         unsigned char per_commitment_secret_arr[32];
35149         CHECK(per_commitment_secret->arr_len == 32);
35150         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
35151         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
35152         unsigned char countersignatory_revocation_base_secret_arr[32];
35153         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
35154         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
35155         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
35156         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35157         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
35158         return (uint32_t)ret_conv;
35159 }
35160
35161 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) {
35162         LDKPublicKey per_commitment_point_ref;
35163         CHECK(per_commitment_point->arr_len == 33);
35164         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35165         LDKPublicKey countersignatory_revocation_base_point_ref;
35166         CHECK(countersignatory_revocation_base_point->arr_len == 33);
35167         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
35168         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35169         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
35170         return (uint32_t)ret_conv;
35171 }
35172
35173 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
35174         LDKTxCreationKeys this_obj_conv;
35175         this_obj_conv.inner = (void*)(this_obj & (~1));
35176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35178         TxCreationKeys_free(this_obj_conv);
35179 }
35180
35181 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
35182         LDKTxCreationKeys this_ptr_conv;
35183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35184         this_ptr_conv.is_owned = false;
35185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35186         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35187         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
35188         return ret_arr;
35189 }
35190
35191 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
35192         LDKTxCreationKeys this_ptr_conv;
35193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35194         this_ptr_conv.is_owned = false;
35195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35196         LDKPublicKey val_ref;
35197         CHECK(val->arr_len == 33);
35198         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35199         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
35200 }
35201
35202 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
35203         LDKTxCreationKeys this_ptr_conv;
35204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35205         this_ptr_conv.is_owned = false;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35207         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35208         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
35209         return ret_arr;
35210 }
35211
35212 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
35213         LDKTxCreationKeys this_ptr_conv;
35214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35215         this_ptr_conv.is_owned = false;
35216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35217         LDKPublicKey val_ref;
35218         CHECK(val->arr_len == 33);
35219         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35220         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
35221 }
35222
35223 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
35224         LDKTxCreationKeys this_ptr_conv;
35225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35226         this_ptr_conv.is_owned = false;
35227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35228         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35229         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
35230         return ret_arr;
35231 }
35232
35233 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
35234         LDKTxCreationKeys this_ptr_conv;
35235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35236         this_ptr_conv.is_owned = false;
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35238         LDKPublicKey val_ref;
35239         CHECK(val->arr_len == 33);
35240         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35241         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
35242 }
35243
35244 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
35245         LDKTxCreationKeys this_ptr_conv;
35246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35247         this_ptr_conv.is_owned = false;
35248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35249         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35250         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
35251         return ret_arr;
35252 }
35253
35254 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
35255         LDKTxCreationKeys this_ptr_conv;
35256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35257         this_ptr_conv.is_owned = false;
35258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35259         LDKPublicKey val_ref;
35260         CHECK(val->arr_len == 33);
35261         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35262         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
35263 }
35264
35265 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
35266         LDKTxCreationKeys this_ptr_conv;
35267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35268         this_ptr_conv.is_owned = false;
35269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35270         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35271         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
35272         return ret_arr;
35273 }
35274
35275 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) {
35276         LDKTxCreationKeys this_ptr_conv;
35277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35278         this_ptr_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35280         LDKPublicKey val_ref;
35281         CHECK(val->arr_len == 33);
35282         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35283         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
35284 }
35285
35286 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) {
35287         LDKPublicKey per_commitment_point_arg_ref;
35288         CHECK(per_commitment_point_arg->arr_len == 33);
35289         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
35290         LDKPublicKey revocation_key_arg_ref;
35291         CHECK(revocation_key_arg->arr_len == 33);
35292         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
35293         LDKPublicKey broadcaster_htlc_key_arg_ref;
35294         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
35295         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
35296         LDKPublicKey countersignatory_htlc_key_arg_ref;
35297         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
35298         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
35299         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
35300         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
35301         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
35302         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);
35303         uint32_t ret_ref = 0;
35304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35307         ret_ref = (uintptr_t)ret_var.inner;
35308         if (ret_var.is_owned) {
35309                 ret_ref |= 1;
35310         }
35311         return ret_ref;
35312 }
35313
35314 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
35315         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
35316 uint32_t ret_ref = 0;
35317 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35318 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35319 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35320 ret_ref = (uintptr_t)ret_var.inner;
35321 if (ret_var.is_owned) {
35322         ret_ref |= 1;
35323 }
35324         return ret_ref;
35325 }
35326 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
35327         LDKTxCreationKeys arg_conv;
35328         arg_conv.inner = (void*)(arg & (~1));
35329         arg_conv.is_owned = false;
35330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35331         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
35332         return ret_conv;
35333 }
35334
35335 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
35336         LDKTxCreationKeys orig_conv;
35337         orig_conv.inner = (void*)(orig & (~1));
35338         orig_conv.is_owned = false;
35339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35340         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
35341         uint32_t ret_ref = 0;
35342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35345         ret_ref = (uintptr_t)ret_var.inner;
35346         if (ret_var.is_owned) {
35347                 ret_ref |= 1;
35348         }
35349         return ret_ref;
35350 }
35351
35352 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
35353         LDKTxCreationKeys obj_conv;
35354         obj_conv.inner = (void*)(obj & (~1));
35355         obj_conv.is_owned = false;
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35357         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
35358         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35359         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35360         CVec_u8Z_free(ret_var);
35361         return ret_arr;
35362 }
35363
35364 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
35365         LDKu8slice ser_ref;
35366         ser_ref.datalen = ser->arr_len;
35367         ser_ref.data = ser->elems;
35368         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
35369         *ret_conv = TxCreationKeys_read(ser_ref);
35370         FREE(ser);
35371         return (uint32_t)ret_conv;
35372 }
35373
35374 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
35375         LDKChannelPublicKeys this_obj_conv;
35376         this_obj_conv.inner = (void*)(this_obj & (~1));
35377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35379         ChannelPublicKeys_free(this_obj_conv);
35380 }
35381
35382 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
35383         LDKChannelPublicKeys this_ptr_conv;
35384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35385         this_ptr_conv.is_owned = false;
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35388         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
35389         return ret_arr;
35390 }
35391
35392 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
35393         LDKChannelPublicKeys this_ptr_conv;
35394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35395         this_ptr_conv.is_owned = false;
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35397         LDKPublicKey val_ref;
35398         CHECK(val->arr_len == 33);
35399         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35400         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
35401 }
35402
35403 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
35404         LDKChannelPublicKeys this_ptr_conv;
35405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35406         this_ptr_conv.is_owned = false;
35407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35408         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35409         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
35410         return ret_arr;
35411 }
35412
35413 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
35414         LDKChannelPublicKeys this_ptr_conv;
35415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35416         this_ptr_conv.is_owned = false;
35417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35418         LDKPublicKey val_ref;
35419         CHECK(val->arr_len == 33);
35420         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35421         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
35422 }
35423
35424 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
35425         LDKChannelPublicKeys this_ptr_conv;
35426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35427         this_ptr_conv.is_owned = false;
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35429         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35430         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
35431         return ret_arr;
35432 }
35433
35434 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
35435         LDKChannelPublicKeys this_ptr_conv;
35436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35437         this_ptr_conv.is_owned = false;
35438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35439         LDKPublicKey val_ref;
35440         CHECK(val->arr_len == 33);
35441         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35442         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
35443 }
35444
35445 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
35446         LDKChannelPublicKeys this_ptr_conv;
35447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35448         this_ptr_conv.is_owned = false;
35449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35450         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35451         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
35452         return ret_arr;
35453 }
35454
35455 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
35456         LDKChannelPublicKeys this_ptr_conv;
35457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35458         this_ptr_conv.is_owned = false;
35459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35460         LDKPublicKey val_ref;
35461         CHECK(val->arr_len == 33);
35462         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35463         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35464 }
35465
35466 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
35467         LDKChannelPublicKeys this_ptr_conv;
35468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35469         this_ptr_conv.is_owned = false;
35470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35471         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35472         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
35473         return ret_arr;
35474 }
35475
35476 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
35477         LDKChannelPublicKeys this_ptr_conv;
35478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35479         this_ptr_conv.is_owned = false;
35480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35481         LDKPublicKey val_ref;
35482         CHECK(val->arr_len == 33);
35483         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35484         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
35485 }
35486
35487 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) {
35488         LDKPublicKey funding_pubkey_arg_ref;
35489         CHECK(funding_pubkey_arg->arr_len == 33);
35490         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
35491         LDKPublicKey revocation_basepoint_arg_ref;
35492         CHECK(revocation_basepoint_arg->arr_len == 33);
35493         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
35494         LDKPublicKey payment_point_arg_ref;
35495         CHECK(payment_point_arg->arr_len == 33);
35496         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
35497         LDKPublicKey delayed_payment_basepoint_arg_ref;
35498         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
35499         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
35500         LDKPublicKey htlc_basepoint_arg_ref;
35501         CHECK(htlc_basepoint_arg->arr_len == 33);
35502         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
35503         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);
35504         uint32_t ret_ref = 0;
35505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35508         ret_ref = (uintptr_t)ret_var.inner;
35509         if (ret_var.is_owned) {
35510                 ret_ref |= 1;
35511         }
35512         return ret_ref;
35513 }
35514
35515 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
35516         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
35517 uint32_t ret_ref = 0;
35518 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35519 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35521 ret_ref = (uintptr_t)ret_var.inner;
35522 if (ret_var.is_owned) {
35523         ret_ref |= 1;
35524 }
35525         return ret_ref;
35526 }
35527 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
35528         LDKChannelPublicKeys arg_conv;
35529         arg_conv.inner = (void*)(arg & (~1));
35530         arg_conv.is_owned = false;
35531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35532         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
35533         return ret_conv;
35534 }
35535
35536 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
35537         LDKChannelPublicKeys orig_conv;
35538         orig_conv.inner = (void*)(orig & (~1));
35539         orig_conv.is_owned = false;
35540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35541         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
35542         uint32_t ret_ref = 0;
35543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35546         ret_ref = (uintptr_t)ret_var.inner;
35547         if (ret_var.is_owned) {
35548                 ret_ref |= 1;
35549         }
35550         return ret_ref;
35551 }
35552
35553 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
35554         LDKChannelPublicKeys obj_conv;
35555         obj_conv.inner = (void*)(obj & (~1));
35556         obj_conv.is_owned = false;
35557         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35558         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
35559         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35560         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35561         CVec_u8Z_free(ret_var);
35562         return ret_arr;
35563 }
35564
35565 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
35566         LDKu8slice ser_ref;
35567         ser_ref.datalen = ser->arr_len;
35568         ser_ref.data = ser->elems;
35569         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
35570         *ret_conv = ChannelPublicKeys_read(ser_ref);
35571         FREE(ser);
35572         return (uint32_t)ret_conv;
35573 }
35574
35575 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) {
35576         LDKPublicKey per_commitment_point_ref;
35577         CHECK(per_commitment_point->arr_len == 33);
35578         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35579         LDKPublicKey broadcaster_delayed_payment_base_ref;
35580         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
35581         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
35582         LDKPublicKey broadcaster_htlc_base_ref;
35583         CHECK(broadcaster_htlc_base->arr_len == 33);
35584         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
35585         LDKPublicKey countersignatory_revocation_base_ref;
35586         CHECK(countersignatory_revocation_base->arr_len == 33);
35587         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
35588         LDKPublicKey countersignatory_htlc_base_ref;
35589         CHECK(countersignatory_htlc_base->arr_len == 33);
35590         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
35591         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35592         *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);
35593         return (uint32_t)ret_conv;
35594 }
35595
35596 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) {
35597         LDKPublicKey per_commitment_point_ref;
35598         CHECK(per_commitment_point->arr_len == 33);
35599         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35600         LDKChannelPublicKeys broadcaster_keys_conv;
35601         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
35602         broadcaster_keys_conv.is_owned = false;
35603         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
35604         LDKChannelPublicKeys countersignatory_keys_conv;
35605         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
35606         countersignatory_keys_conv.is_owned = false;
35607         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
35608         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35609         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
35610         return (uint32_t)ret_conv;
35611 }
35612
35613 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) {
35614         LDKPublicKey revocation_key_ref;
35615         CHECK(revocation_key->arr_len == 33);
35616         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35617         LDKPublicKey broadcaster_delayed_payment_key_ref;
35618         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35619         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35620         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
35621         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35622         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35623         CVec_u8Z_free(ret_var);
35624         return ret_arr;
35625 }
35626
35627 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
35628         LDKHTLCOutputInCommitment this_obj_conv;
35629         this_obj_conv.inner = (void*)(this_obj & (~1));
35630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35632         HTLCOutputInCommitment_free(this_obj_conv);
35633 }
35634
35635 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
35636         LDKHTLCOutputInCommitment this_ptr_conv;
35637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35638         this_ptr_conv.is_owned = false;
35639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35640         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
35641         return ret_conv;
35642 }
35643
35644 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
35645         LDKHTLCOutputInCommitment 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         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
35650 }
35651
35652 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
35653         LDKHTLCOutputInCommitment this_ptr_conv;
35654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35655         this_ptr_conv.is_owned = false;
35656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35657         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
35658         return ret_conv;
35659 }
35660
35661 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
35662         LDKHTLCOutputInCommitment this_ptr_conv;
35663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35664         this_ptr_conv.is_owned = false;
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35666         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
35667 }
35668
35669 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
35670         LDKHTLCOutputInCommitment this_ptr_conv;
35671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35672         this_ptr_conv.is_owned = false;
35673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35674         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
35675         return ret_conv;
35676 }
35677
35678 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
35679         LDKHTLCOutputInCommitment this_ptr_conv;
35680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35681         this_ptr_conv.is_owned = false;
35682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35683         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
35684 }
35685
35686 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
35687         LDKHTLCOutputInCommitment this_ptr_conv;
35688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35689         this_ptr_conv.is_owned = false;
35690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35691         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35692         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
35693         return ret_arr;
35694 }
35695
35696 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
35697         LDKHTLCOutputInCommitment this_ptr_conv;
35698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35699         this_ptr_conv.is_owned = false;
35700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35701         LDKThirtyTwoBytes val_ref;
35702         CHECK(val->arr_len == 32);
35703         memcpy(val_ref.data, val->elems, 32); FREE(val);
35704         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35705 }
35706
35707 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
35708         LDKHTLCOutputInCommitment this_ptr_conv;
35709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35710         this_ptr_conv.is_owned = false;
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35712         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35713         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35714         uint32_t ret_ref = (uintptr_t)ret_copy;
35715         return ret_ref;
35716 }
35717
35718 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
35719         LDKHTLCOutputInCommitment this_ptr_conv;
35720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35721         this_ptr_conv.is_owned = false;
35722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35723         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35724         CHECK_ACCESS(val_ptr);
35725         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35726         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
35727         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35728 }
35729
35730 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) {
35731         LDKThirtyTwoBytes payment_hash_arg_ref;
35732         CHECK(payment_hash_arg->arr_len == 32);
35733         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35734         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
35735         CHECK_ACCESS(transaction_output_index_arg_ptr);
35736         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35737         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
35738         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35739         uint32_t ret_ref = 0;
35740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35743         ret_ref = (uintptr_t)ret_var.inner;
35744         if (ret_var.is_owned) {
35745                 ret_ref |= 1;
35746         }
35747         return ret_ref;
35748 }
35749
35750 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35751         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35752 uint32_t ret_ref = 0;
35753 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35754 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35756 ret_ref = (uintptr_t)ret_var.inner;
35757 if (ret_var.is_owned) {
35758         ret_ref |= 1;
35759 }
35760         return ret_ref;
35761 }
35762 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
35763         LDKHTLCOutputInCommitment arg_conv;
35764         arg_conv.inner = (void*)(arg & (~1));
35765         arg_conv.is_owned = false;
35766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35767         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35768         return ret_conv;
35769 }
35770
35771 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
35772         LDKHTLCOutputInCommitment orig_conv;
35773         orig_conv.inner = (void*)(orig & (~1));
35774         orig_conv.is_owned = false;
35775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35776         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35777         uint32_t ret_ref = 0;
35778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35781         ret_ref = (uintptr_t)ret_var.inner;
35782         if (ret_var.is_owned) {
35783                 ret_ref |= 1;
35784         }
35785         return ret_ref;
35786 }
35787
35788 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
35789         LDKHTLCOutputInCommitment obj_conv;
35790         obj_conv.inner = (void*)(obj & (~1));
35791         obj_conv.is_owned = false;
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35793         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35794         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35795         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35796         CVec_u8Z_free(ret_var);
35797         return ret_arr;
35798 }
35799
35800 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35801         LDKu8slice ser_ref;
35802         ser_ref.datalen = ser->arr_len;
35803         ser_ref.data = ser->elems;
35804         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35805         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35806         FREE(ser);
35807         return (uint32_t)ret_conv;
35808 }
35809
35810 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
35811         LDKHTLCOutputInCommitment htlc_conv;
35812         htlc_conv.inner = (void*)(htlc & (~1));
35813         htlc_conv.is_owned = false;
35814         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35815         LDKTxCreationKeys keys_conv;
35816         keys_conv.inner = (void*)(keys & (~1));
35817         keys_conv.is_owned = false;
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35819         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35820         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35821         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35822         CVec_u8Z_free(ret_var);
35823         return ret_arr;
35824 }
35825
35826 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35827         LDKPublicKey broadcaster_ref;
35828         CHECK(broadcaster->arr_len == 33);
35829         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35830         LDKPublicKey countersignatory_ref;
35831         CHECK(countersignatory->arr_len == 33);
35832         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35833         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35834         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35835         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35836         CVec_u8Z_free(ret_var);
35837         return ret_arr;
35838 }
35839
35840 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) {
35841         unsigned char commitment_txid_arr[32];
35842         CHECK(commitment_txid->arr_len == 32);
35843         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35844         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35845         LDKHTLCOutputInCommitment htlc_conv;
35846         htlc_conv.inner = (void*)(htlc & (~1));
35847         htlc_conv.is_owned = false;
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35849         LDKPublicKey broadcaster_delayed_payment_key_ref;
35850         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35851         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35852         LDKPublicKey revocation_key_ref;
35853         CHECK(revocation_key->arr_len == 33);
35854         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35855         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);
35856         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35857         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35858         Transaction_free(ret_var);
35859         return ret_arr;
35860 }
35861
35862 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35863         LDKPublicKey funding_pubkey_ref;
35864         CHECK(funding_pubkey->arr_len == 33);
35865         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35866         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35867         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35868         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35869         CVec_u8Z_free(ret_var);
35870         return ret_arr;
35871 }
35872
35873 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
35874         LDKChannelTransactionParameters this_obj_conv;
35875         this_obj_conv.inner = (void*)(this_obj & (~1));
35876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35878         ChannelTransactionParameters_free(this_obj_conv);
35879 }
35880
35881 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
35882         LDKChannelTransactionParameters this_ptr_conv;
35883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35884         this_ptr_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35886         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35887         uint32_t ret_ref = 0;
35888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35891         ret_ref = (uintptr_t)ret_var.inner;
35892         if (ret_var.is_owned) {
35893                 ret_ref |= 1;
35894         }
35895         return ret_ref;
35896 }
35897
35898 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
35899         LDKChannelTransactionParameters this_ptr_conv;
35900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35901         this_ptr_conv.is_owned = false;
35902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35903         LDKChannelPublicKeys val_conv;
35904         val_conv.inner = (void*)(val & (~1));
35905         val_conv.is_owned = (val & 1) || (val == 0);
35906         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35907         val_conv = ChannelPublicKeys_clone(&val_conv);
35908         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
35909 }
35910
35911 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
35912         LDKChannelTransactionParameters this_ptr_conv;
35913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35914         this_ptr_conv.is_owned = false;
35915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35916         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
35917         return ret_conv;
35918 }
35919
35920 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) {
35921         LDKChannelTransactionParameters this_ptr_conv;
35922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35923         this_ptr_conv.is_owned = false;
35924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35925         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
35926 }
35927
35928 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
35929         LDKChannelTransactionParameters this_ptr_conv;
35930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35931         this_ptr_conv.is_owned = false;
35932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35933         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
35934         return ret_conv;
35935 }
35936
35937 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
35938         LDKChannelTransactionParameters 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         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
35943 }
35944
35945 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
35946         LDKChannelTransactionParameters this_ptr_conv;
35947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35948         this_ptr_conv.is_owned = false;
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35950         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
35951         uint32_t ret_ref = 0;
35952         if ((uintptr_t)ret_var.inner > 4096) {
35953                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35954                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35956                 ret_ref = (uintptr_t)ret_var.inner;
35957                 if (ret_var.is_owned) {
35958                         ret_ref |= 1;
35959                 }
35960         }
35961         return ret_ref;
35962 }
35963
35964 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
35965         LDKChannelTransactionParameters this_ptr_conv;
35966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35967         this_ptr_conv.is_owned = false;
35968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35969         LDKCounterpartyChannelTransactionParameters val_conv;
35970         val_conv.inner = (void*)(val & (~1));
35971         val_conv.is_owned = (val & 1) || (val == 0);
35972         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35973         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
35974         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
35975 }
35976
35977 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
35978         LDKChannelTransactionParameters this_ptr_conv;
35979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35980         this_ptr_conv.is_owned = false;
35981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35982         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
35983         uint32_t ret_ref = 0;
35984         if ((uintptr_t)ret_var.inner > 4096) {
35985                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35986                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35988                 ret_ref = (uintptr_t)ret_var.inner;
35989                 if (ret_var.is_owned) {
35990                         ret_ref |= 1;
35991                 }
35992         }
35993         return ret_ref;
35994 }
35995
35996 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
35997         LDKChannelTransactionParameters this_ptr_conv;
35998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35999         this_ptr_conv.is_owned = false;
36000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36001         LDKOutPoint val_conv;
36002         val_conv.inner = (void*)(val & (~1));
36003         val_conv.is_owned = (val & 1) || (val == 0);
36004         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36005         val_conv = OutPoint_clone(&val_conv);
36006         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
36007 }
36008
36009 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
36010         LDKChannelTransactionParameters this_ptr_conv;
36011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36012         this_ptr_conv.is_owned = false;
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36014         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
36015         return ret_conv;
36016 }
36017
36018 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
36019         LDKChannelTransactionParameters this_ptr_conv;
36020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36021         this_ptr_conv.is_owned = false;
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36023         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
36024         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
36025 }
36026
36027 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) {
36028         LDKChannelPublicKeys holder_pubkeys_arg_conv;
36029         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
36030         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
36031         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
36032         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
36033         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
36034         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
36035         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
36036         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
36037         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
36038         LDKOutPoint funding_outpoint_arg_conv;
36039         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
36040         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
36041         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
36042         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
36043         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
36044         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);
36045         uint32_t ret_ref = 0;
36046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36049         ret_ref = (uintptr_t)ret_var.inner;
36050         if (ret_var.is_owned) {
36051                 ret_ref |= 1;
36052         }
36053         return ret_ref;
36054 }
36055
36056 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
36057         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
36058 uint32_t ret_ref = 0;
36059 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36060 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36061 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36062 ret_ref = (uintptr_t)ret_var.inner;
36063 if (ret_var.is_owned) {
36064         ret_ref |= 1;
36065 }
36066         return ret_ref;
36067 }
36068 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
36069         LDKChannelTransactionParameters arg_conv;
36070         arg_conv.inner = (void*)(arg & (~1));
36071         arg_conv.is_owned = false;
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36073         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
36074         return ret_conv;
36075 }
36076
36077 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
36078         LDKChannelTransactionParameters orig_conv;
36079         orig_conv.inner = (void*)(orig & (~1));
36080         orig_conv.is_owned = false;
36081         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36082         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
36083         uint32_t ret_ref = 0;
36084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36087         ret_ref = (uintptr_t)ret_var.inner;
36088         if (ret_var.is_owned) {
36089                 ret_ref |= 1;
36090         }
36091         return ret_ref;
36092 }
36093
36094 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
36095         LDKCounterpartyChannelTransactionParameters this_obj_conv;
36096         this_obj_conv.inner = (void*)(this_obj & (~1));
36097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36099         CounterpartyChannelTransactionParameters_free(this_obj_conv);
36100 }
36101
36102 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
36103         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36105         this_ptr_conv.is_owned = false;
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36107         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
36108         uint32_t ret_ref = 0;
36109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36112         ret_ref = (uintptr_t)ret_var.inner;
36113         if (ret_var.is_owned) {
36114                 ret_ref |= 1;
36115         }
36116         return ret_ref;
36117 }
36118
36119 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
36120         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36122         this_ptr_conv.is_owned = false;
36123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36124         LDKChannelPublicKeys val_conv;
36125         val_conv.inner = (void*)(val & (~1));
36126         val_conv.is_owned = (val & 1) || (val == 0);
36127         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36128         val_conv = ChannelPublicKeys_clone(&val_conv);
36129         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
36130 }
36131
36132 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
36133         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36135         this_ptr_conv.is_owned = false;
36136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36137         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
36138         return ret_conv;
36139 }
36140
36141 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
36142         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36144         this_ptr_conv.is_owned = false;
36145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36146         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
36147 }
36148
36149 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
36150         LDKChannelPublicKeys pubkeys_arg_conv;
36151         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
36152         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
36154         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
36155         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
36156         uint32_t ret_ref = 0;
36157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36160         ret_ref = (uintptr_t)ret_var.inner;
36161         if (ret_var.is_owned) {
36162                 ret_ref |= 1;
36163         }
36164         return ret_ref;
36165 }
36166
36167 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
36168         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
36169 uint32_t ret_ref = 0;
36170 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36171 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36173 ret_ref = (uintptr_t)ret_var.inner;
36174 if (ret_var.is_owned) {
36175         ret_ref |= 1;
36176 }
36177         return ret_ref;
36178 }
36179 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
36180         LDKCounterpartyChannelTransactionParameters arg_conv;
36181         arg_conv.inner = (void*)(arg & (~1));
36182         arg_conv.is_owned = false;
36183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36184         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
36185         return ret_conv;
36186 }
36187
36188 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
36189         LDKCounterpartyChannelTransactionParameters orig_conv;
36190         orig_conv.inner = (void*)(orig & (~1));
36191         orig_conv.is_owned = false;
36192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36193         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
36194         uint32_t ret_ref = 0;
36195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36198         ret_ref = (uintptr_t)ret_var.inner;
36199         if (ret_var.is_owned) {
36200                 ret_ref |= 1;
36201         }
36202         return ret_ref;
36203 }
36204
36205 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
36206         LDKChannelTransactionParameters this_arg_conv;
36207         this_arg_conv.inner = (void*)(this_arg & (~1));
36208         this_arg_conv.is_owned = false;
36209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36210         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
36211         return ret_conv;
36212 }
36213
36214 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
36215         LDKChannelTransactionParameters this_arg_conv;
36216         this_arg_conv.inner = (void*)(this_arg & (~1));
36217         this_arg_conv.is_owned = false;
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36219         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
36220         uint32_t ret_ref = 0;
36221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36224         ret_ref = (uintptr_t)ret_var.inner;
36225         if (ret_var.is_owned) {
36226                 ret_ref |= 1;
36227         }
36228         return ret_ref;
36229 }
36230
36231 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
36232         LDKChannelTransactionParameters this_arg_conv;
36233         this_arg_conv.inner = (void*)(this_arg & (~1));
36234         this_arg_conv.is_owned = false;
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36236         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
36237         uint32_t ret_ref = 0;
36238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36241         ret_ref = (uintptr_t)ret_var.inner;
36242         if (ret_var.is_owned) {
36243                 ret_ref |= 1;
36244         }
36245         return ret_ref;
36246 }
36247
36248 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
36249         LDKCounterpartyChannelTransactionParameters obj_conv;
36250         obj_conv.inner = (void*)(obj & (~1));
36251         obj_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36253         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
36254         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36255         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36256         CVec_u8Z_free(ret_var);
36257         return ret_arr;
36258 }
36259
36260 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
36261         LDKu8slice ser_ref;
36262         ser_ref.datalen = ser->arr_len;
36263         ser_ref.data = ser->elems;
36264         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
36265         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
36266         FREE(ser);
36267         return (uint32_t)ret_conv;
36268 }
36269
36270 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
36271         LDKChannelTransactionParameters obj_conv;
36272         obj_conv.inner = (void*)(obj & (~1));
36273         obj_conv.is_owned = false;
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36275         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
36276         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36277         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36278         CVec_u8Z_free(ret_var);
36279         return ret_arr;
36280 }
36281
36282 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
36283         LDKu8slice ser_ref;
36284         ser_ref.datalen = ser->arr_len;
36285         ser_ref.data = ser->elems;
36286         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
36287         *ret_conv = ChannelTransactionParameters_read(ser_ref);
36288         FREE(ser);
36289         return (uint32_t)ret_conv;
36290 }
36291
36292 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
36293         LDKDirectedChannelTransactionParameters this_obj_conv;
36294         this_obj_conv.inner = (void*)(this_obj & (~1));
36295         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36297         DirectedChannelTransactionParameters_free(this_obj_conv);
36298 }
36299
36300 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
36301         LDKDirectedChannelTransactionParameters this_arg_conv;
36302         this_arg_conv.inner = (void*)(this_arg & (~1));
36303         this_arg_conv.is_owned = false;
36304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36305         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
36306         uint32_t ret_ref = 0;
36307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36310         ret_ref = (uintptr_t)ret_var.inner;
36311         if (ret_var.is_owned) {
36312                 ret_ref |= 1;
36313         }
36314         return ret_ref;
36315 }
36316
36317 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
36318         LDKDirectedChannelTransactionParameters this_arg_conv;
36319         this_arg_conv.inner = (void*)(this_arg & (~1));
36320         this_arg_conv.is_owned = false;
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36322         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
36323         uint32_t ret_ref = 0;
36324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36327         ret_ref = (uintptr_t)ret_var.inner;
36328         if (ret_var.is_owned) {
36329                 ret_ref |= 1;
36330         }
36331         return ret_ref;
36332 }
36333
36334 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
36335         LDKDirectedChannelTransactionParameters this_arg_conv;
36336         this_arg_conv.inner = (void*)(this_arg & (~1));
36337         this_arg_conv.is_owned = false;
36338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36339         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
36340         return ret_conv;
36341 }
36342
36343 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
36344         LDKDirectedChannelTransactionParameters this_arg_conv;
36345         this_arg_conv.inner = (void*)(this_arg & (~1));
36346         this_arg_conv.is_owned = false;
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36348         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
36349         return ret_conv;
36350 }
36351
36352 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
36353         LDKDirectedChannelTransactionParameters this_arg_conv;
36354         this_arg_conv.inner = (void*)(this_arg & (~1));
36355         this_arg_conv.is_owned = false;
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36357         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
36358         uint32_t ret_ref = 0;
36359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36362         ret_ref = (uintptr_t)ret_var.inner;
36363         if (ret_var.is_owned) {
36364                 ret_ref |= 1;
36365         }
36366         return ret_ref;
36367 }
36368
36369 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
36370         LDKDirectedChannelTransactionParameters this_arg_conv;
36371         this_arg_conv.inner = (void*)(this_arg & (~1));
36372         this_arg_conv.is_owned = false;
36373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36374         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
36375         return ret_conv;
36376 }
36377
36378 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
36379         LDKHolderCommitmentTransaction this_obj_conv;
36380         this_obj_conv.inner = (void*)(this_obj & (~1));
36381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36383         HolderCommitmentTransaction_free(this_obj_conv);
36384 }
36385
36386 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
36387         LDKHolderCommitmentTransaction this_ptr_conv;
36388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36389         this_ptr_conv.is_owned = false;
36390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36391         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36392         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
36393         return ret_arr;
36394 }
36395
36396 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
36397         LDKHolderCommitmentTransaction this_ptr_conv;
36398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36399         this_ptr_conv.is_owned = false;
36400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36401         LDKSignature val_ref;
36402         CHECK(val->arr_len == 64);
36403         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
36404         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
36405 }
36406
36407 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
36408         LDKHolderCommitmentTransaction this_ptr_conv;
36409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36410         this_ptr_conv.is_owned = false;
36411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36412         LDKCVec_SignatureZ val_constr;
36413         val_constr.datalen = val->arr_len;
36414         if (val_constr.datalen > 0)
36415                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36416         else
36417                 val_constr.data = NULL;
36418         int8_tArray* val_vals = (void*) val->elems;
36419         for (size_t m = 0; m < val_constr.datalen; m++) {
36420                 int8_tArray val_conv_12 = val_vals[m];
36421                 LDKSignature val_conv_12_ref;
36422                 CHECK(val_conv_12->arr_len == 64);
36423                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
36424                 val_constr.data[m] = val_conv_12_ref;
36425         }
36426         FREE(val);
36427         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
36428 }
36429
36430 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
36431         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
36432 uint32_t ret_ref = 0;
36433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36436 ret_ref = (uintptr_t)ret_var.inner;
36437 if (ret_var.is_owned) {
36438         ret_ref |= 1;
36439 }
36440         return ret_ref;
36441 }
36442 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
36443         LDKHolderCommitmentTransaction arg_conv;
36444         arg_conv.inner = (void*)(arg & (~1));
36445         arg_conv.is_owned = false;
36446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36447         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
36448         return ret_conv;
36449 }
36450
36451 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
36452         LDKHolderCommitmentTransaction orig_conv;
36453         orig_conv.inner = (void*)(orig & (~1));
36454         orig_conv.is_owned = false;
36455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36456         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
36457         uint32_t ret_ref = 0;
36458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36461         ret_ref = (uintptr_t)ret_var.inner;
36462         if (ret_var.is_owned) {
36463                 ret_ref |= 1;
36464         }
36465         return ret_ref;
36466 }
36467
36468 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
36469         LDKHolderCommitmentTransaction obj_conv;
36470         obj_conv.inner = (void*)(obj & (~1));
36471         obj_conv.is_owned = false;
36472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36473         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
36474         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36475         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36476         CVec_u8Z_free(ret_var);
36477         return ret_arr;
36478 }
36479
36480 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
36481         LDKu8slice ser_ref;
36482         ser_ref.datalen = ser->arr_len;
36483         ser_ref.data = ser->elems;
36484         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
36485         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
36486         FREE(ser);
36487         return (uint32_t)ret_conv;
36488 }
36489
36490 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) {
36491         LDKCommitmentTransaction commitment_tx_conv;
36492         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
36493         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
36494         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
36495         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
36496         LDKSignature counterparty_sig_ref;
36497         CHECK(counterparty_sig->arr_len == 64);
36498         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
36499         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
36500         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
36501         if (counterparty_htlc_sigs_constr.datalen > 0)
36502                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36503         else
36504                 counterparty_htlc_sigs_constr.data = NULL;
36505         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
36506         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
36507                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
36508                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
36509                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
36510                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
36511                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
36512         }
36513         FREE(counterparty_htlc_sigs);
36514         LDKPublicKey holder_funding_key_ref;
36515         CHECK(holder_funding_key->arr_len == 33);
36516         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
36517         LDKPublicKey counterparty_funding_key_ref;
36518         CHECK(counterparty_funding_key->arr_len == 33);
36519         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
36520         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
36521         uint32_t ret_ref = 0;
36522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36525         ret_ref = (uintptr_t)ret_var.inner;
36526         if (ret_var.is_owned) {
36527                 ret_ref |= 1;
36528         }
36529         return ret_ref;
36530 }
36531
36532 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
36533         LDKBuiltCommitmentTransaction this_obj_conv;
36534         this_obj_conv.inner = (void*)(this_obj & (~1));
36535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36537         BuiltCommitmentTransaction_free(this_obj_conv);
36538 }
36539
36540 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
36541         LDKBuiltCommitmentTransaction this_ptr_conv;
36542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36543         this_ptr_conv.is_owned = false;
36544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36545         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
36546         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36547         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36548         Transaction_free(ret_var);
36549         return ret_arr;
36550 }
36551
36552 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
36553         LDKBuiltCommitmentTransaction this_ptr_conv;
36554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36555         this_ptr_conv.is_owned = false;
36556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36557         LDKTransaction val_ref;
36558         val_ref.datalen = val->arr_len;
36559         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
36560         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
36561         val_ref.data_is_owned = true;
36562         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
36563 }
36564
36565 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
36566         LDKBuiltCommitmentTransaction this_ptr_conv;
36567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36568         this_ptr_conv.is_owned = false;
36569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36570         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36571         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
36572         return ret_arr;
36573 }
36574
36575 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
36576         LDKBuiltCommitmentTransaction this_ptr_conv;
36577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36578         this_ptr_conv.is_owned = false;
36579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36580         LDKThirtyTwoBytes val_ref;
36581         CHECK(val->arr_len == 32);
36582         memcpy(val_ref.data, val->elems, 32); FREE(val);
36583         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
36584 }
36585
36586 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
36587         LDKTransaction transaction_arg_ref;
36588         transaction_arg_ref.datalen = transaction_arg->arr_len;
36589         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
36590         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
36591         transaction_arg_ref.data_is_owned = true;
36592         LDKThirtyTwoBytes txid_arg_ref;
36593         CHECK(txid_arg->arr_len == 32);
36594         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
36595         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
36596         uint32_t ret_ref = 0;
36597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36600         ret_ref = (uintptr_t)ret_var.inner;
36601         if (ret_var.is_owned) {
36602                 ret_ref |= 1;
36603         }
36604         return ret_ref;
36605 }
36606
36607 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
36608         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
36609 uint32_t ret_ref = 0;
36610 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36611 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36612 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36613 ret_ref = (uintptr_t)ret_var.inner;
36614 if (ret_var.is_owned) {
36615         ret_ref |= 1;
36616 }
36617         return ret_ref;
36618 }
36619 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
36620         LDKBuiltCommitmentTransaction arg_conv;
36621         arg_conv.inner = (void*)(arg & (~1));
36622         arg_conv.is_owned = false;
36623         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36624         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
36625         return ret_conv;
36626 }
36627
36628 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
36629         LDKBuiltCommitmentTransaction orig_conv;
36630         orig_conv.inner = (void*)(orig & (~1));
36631         orig_conv.is_owned = false;
36632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36633         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
36634         uint32_t ret_ref = 0;
36635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36638         ret_ref = (uintptr_t)ret_var.inner;
36639         if (ret_var.is_owned) {
36640                 ret_ref |= 1;
36641         }
36642         return ret_ref;
36643 }
36644
36645 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
36646         LDKBuiltCommitmentTransaction obj_conv;
36647         obj_conv.inner = (void*)(obj & (~1));
36648         obj_conv.is_owned = false;
36649         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36650         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
36651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36653         CVec_u8Z_free(ret_var);
36654         return ret_arr;
36655 }
36656
36657 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
36658         LDKu8slice ser_ref;
36659         ser_ref.datalen = ser->arr_len;
36660         ser_ref.data = ser->elems;
36661         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
36662         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
36663         FREE(ser);
36664         return (uint32_t)ret_conv;
36665 }
36666
36667 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) {
36668         LDKBuiltCommitmentTransaction this_arg_conv;
36669         this_arg_conv.inner = (void*)(this_arg & (~1));
36670         this_arg_conv.is_owned = false;
36671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36672         LDKu8slice funding_redeemscript_ref;
36673         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36674         funding_redeemscript_ref.data = funding_redeemscript->elems;
36675         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36676         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36677         FREE(funding_redeemscript);
36678         return ret_arr;
36679 }
36680
36681 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) {
36682         LDKBuiltCommitmentTransaction this_arg_conv;
36683         this_arg_conv.inner = (void*)(this_arg & (~1));
36684         this_arg_conv.is_owned = false;
36685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36686         unsigned char funding_key_arr[32];
36687         CHECK(funding_key->arr_len == 32);
36688         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36689         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36690         LDKu8slice funding_redeemscript_ref;
36691         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36692         funding_redeemscript_ref.data = funding_redeemscript->elems;
36693         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36694         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36695         FREE(funding_redeemscript);
36696         return ret_arr;
36697 }
36698
36699 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
36700         LDKClosingTransaction this_obj_conv;
36701         this_obj_conv.inner = (void*)(this_obj & (~1));
36702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36704         ClosingTransaction_free(this_obj_conv);
36705 }
36706
36707 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36708         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36709 uint32_t ret_ref = 0;
36710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36713 ret_ref = (uintptr_t)ret_var.inner;
36714 if (ret_var.is_owned) {
36715         ret_ref |= 1;
36716 }
36717         return ret_ref;
36718 }
36719 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
36720         LDKClosingTransaction arg_conv;
36721         arg_conv.inner = (void*)(arg & (~1));
36722         arg_conv.is_owned = false;
36723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36724         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36725         return ret_conv;
36726 }
36727
36728 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
36729         LDKClosingTransaction orig_conv;
36730         orig_conv.inner = (void*)(orig & (~1));
36731         orig_conv.is_owned = false;
36732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36733         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36734         uint32_t ret_ref = 0;
36735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36738         ret_ref = (uintptr_t)ret_var.inner;
36739         if (ret_var.is_owned) {
36740                 ret_ref |= 1;
36741         }
36742         return ret_ref;
36743 }
36744
36745 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
36746         LDKClosingTransaction o_conv;
36747         o_conv.inner = (void*)(o & (~1));
36748         o_conv.is_owned = false;
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36750         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36751         return ret_conv;
36752 }
36753
36754 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) {
36755         LDKCVec_u8Z to_holder_script_ref;
36756         to_holder_script_ref.datalen = to_holder_script->arr_len;
36757         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36758         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36759         LDKCVec_u8Z to_counterparty_script_ref;
36760         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36761         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36762         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36763         LDKOutPoint funding_outpoint_conv;
36764         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36765         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36767         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36768         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36769         uint32_t ret_ref = 0;
36770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36773         ret_ref = (uintptr_t)ret_var.inner;
36774         if (ret_var.is_owned) {
36775                 ret_ref |= 1;
36776         }
36777         return ret_ref;
36778 }
36779
36780 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
36781         LDKClosingTransaction this_arg_conv;
36782         this_arg_conv.inner = (void*)(this_arg & (~1));
36783         this_arg_conv.is_owned = false;
36784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36785         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36786         uint32_t ret_ref = 0;
36787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36790         ret_ref = (uintptr_t)ret_var.inner;
36791         if (ret_var.is_owned) {
36792                 ret_ref |= 1;
36793         }
36794         return ret_ref;
36795 }
36796
36797 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
36798         LDKClosingTransaction this_arg_conv;
36799         this_arg_conv.inner = (void*)(this_arg & (~1));
36800         this_arg_conv.is_owned = false;
36801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36802         LDKOutPoint funding_outpoint_conv;
36803         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36804         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36805         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36806         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36807         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36808         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36809         return (uint32_t)ret_conv;
36810 }
36811
36812 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
36813         LDKClosingTransaction this_arg_conv;
36814         this_arg_conv.inner = (void*)(this_arg & (~1));
36815         this_arg_conv.is_owned = false;
36816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36817         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36818         return ret_conv;
36819 }
36820
36821 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
36822         LDKClosingTransaction this_arg_conv;
36823         this_arg_conv.inner = (void*)(this_arg & (~1));
36824         this_arg_conv.is_owned = false;
36825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36826         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36827         return ret_conv;
36828 }
36829
36830 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
36831         LDKClosingTransaction this_arg_conv;
36832         this_arg_conv.inner = (void*)(this_arg & (~1));
36833         this_arg_conv.is_owned = false;
36834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36835         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36836         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36837         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36838         return ret_arr;
36839 }
36840
36841 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
36842         LDKClosingTransaction this_arg_conv;
36843         this_arg_conv.inner = (void*)(this_arg & (~1));
36844         this_arg_conv.is_owned = false;
36845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36846         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36847         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36848         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36849         return ret_arr;
36850 }
36851
36852 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
36853         LDKTrustedClosingTransaction this_obj_conv;
36854         this_obj_conv.inner = (void*)(this_obj & (~1));
36855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36857         TrustedClosingTransaction_free(this_obj_conv);
36858 }
36859
36860 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
36861         LDKTrustedClosingTransaction this_arg_conv;
36862         this_arg_conv.inner = (void*)(this_arg & (~1));
36863         this_arg_conv.is_owned = false;
36864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36865         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36866         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36867         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36868         Transaction_free(ret_var);
36869         return ret_arr;
36870 }
36871
36872 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) {
36873         LDKTrustedClosingTransaction this_arg_conv;
36874         this_arg_conv.inner = (void*)(this_arg & (~1));
36875         this_arg_conv.is_owned = false;
36876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36877         LDKu8slice funding_redeemscript_ref;
36878         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36879         funding_redeemscript_ref.data = funding_redeemscript->elems;
36880         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36881         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36882         FREE(funding_redeemscript);
36883         return ret_arr;
36884 }
36885
36886 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) {
36887         LDKTrustedClosingTransaction this_arg_conv;
36888         this_arg_conv.inner = (void*)(this_arg & (~1));
36889         this_arg_conv.is_owned = false;
36890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36891         unsigned char funding_key_arr[32];
36892         CHECK(funding_key->arr_len == 32);
36893         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36894         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36895         LDKu8slice funding_redeemscript_ref;
36896         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36897         funding_redeemscript_ref.data = funding_redeemscript->elems;
36898         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36899         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36900         FREE(funding_redeemscript);
36901         return ret_arr;
36902 }
36903
36904 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
36905         LDKCommitmentTransaction this_obj_conv;
36906         this_obj_conv.inner = (void*)(this_obj & (~1));
36907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36909         CommitmentTransaction_free(this_obj_conv);
36910 }
36911
36912 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
36913         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
36914 uint32_t ret_ref = 0;
36915 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36916 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36918 ret_ref = (uintptr_t)ret_var.inner;
36919 if (ret_var.is_owned) {
36920         ret_ref |= 1;
36921 }
36922         return ret_ref;
36923 }
36924 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
36925         LDKCommitmentTransaction arg_conv;
36926         arg_conv.inner = (void*)(arg & (~1));
36927         arg_conv.is_owned = false;
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36929         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
36930         return ret_conv;
36931 }
36932
36933 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
36934         LDKCommitmentTransaction orig_conv;
36935         orig_conv.inner = (void*)(orig & (~1));
36936         orig_conv.is_owned = false;
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36938         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
36939         uint32_t ret_ref = 0;
36940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36943         ret_ref = (uintptr_t)ret_var.inner;
36944         if (ret_var.is_owned) {
36945                 ret_ref |= 1;
36946         }
36947         return ret_ref;
36948 }
36949
36950 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
36951         LDKCommitmentTransaction obj_conv;
36952         obj_conv.inner = (void*)(obj & (~1));
36953         obj_conv.is_owned = false;
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36955         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
36956         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36957         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36958         CVec_u8Z_free(ret_var);
36959         return ret_arr;
36960 }
36961
36962 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
36963         LDKu8slice ser_ref;
36964         ser_ref.datalen = ser->arr_len;
36965         ser_ref.data = ser->elems;
36966         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
36967         *ret_conv = CommitmentTransaction_read(ser_ref);
36968         FREE(ser);
36969         return (uint32_t)ret_conv;
36970 }
36971
36972 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
36973         LDKCommitmentTransaction this_arg_conv;
36974         this_arg_conv.inner = (void*)(this_arg & (~1));
36975         this_arg_conv.is_owned = false;
36976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36977         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
36978         return ret_conv;
36979 }
36980
36981 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
36982         LDKCommitmentTransaction this_arg_conv;
36983         this_arg_conv.inner = (void*)(this_arg & (~1));
36984         this_arg_conv.is_owned = false;
36985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36986         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
36987         return ret_conv;
36988 }
36989
36990 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
36991         LDKCommitmentTransaction this_arg_conv;
36992         this_arg_conv.inner = (void*)(this_arg & (~1));
36993         this_arg_conv.is_owned = false;
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36995         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
36996         return ret_conv;
36997 }
36998
36999 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
37000         LDKCommitmentTransaction this_arg_conv;
37001         this_arg_conv.inner = (void*)(this_arg & (~1));
37002         this_arg_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37004         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
37005         return ret_conv;
37006 }
37007
37008 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
37009         LDKCommitmentTransaction this_arg_conv;
37010         this_arg_conv.inner = (void*)(this_arg & (~1));
37011         this_arg_conv.is_owned = false;
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37013         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
37014         uint32_t ret_ref = 0;
37015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37018         ret_ref = (uintptr_t)ret_var.inner;
37019         if (ret_var.is_owned) {
37020                 ret_ref |= 1;
37021         }
37022         return ret_ref;
37023 }
37024
37025 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) {
37026         LDKCommitmentTransaction this_arg_conv;
37027         this_arg_conv.inner = (void*)(this_arg & (~1));
37028         this_arg_conv.is_owned = false;
37029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37030         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37031         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37032         channel_parameters_conv.is_owned = false;
37033         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37034         LDKChannelPublicKeys broadcaster_keys_conv;
37035         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37036         broadcaster_keys_conv.is_owned = false;
37037         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37038         LDKChannelPublicKeys countersignatory_keys_conv;
37039         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37040         countersignatory_keys_conv.is_owned = false;
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37042         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
37043         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
37044         return (uint32_t)ret_conv;
37045 }
37046
37047 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
37048         LDKTrustedCommitmentTransaction this_obj_conv;
37049         this_obj_conv.inner = (void*)(this_obj & (~1));
37050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37052         TrustedCommitmentTransaction_free(this_obj_conv);
37053 }
37054
37055 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
37056         LDKTrustedCommitmentTransaction this_arg_conv;
37057         this_arg_conv.inner = (void*)(this_arg & (~1));
37058         this_arg_conv.is_owned = false;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37060         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37061         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
37062         return ret_arr;
37063 }
37064
37065 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
37066         LDKTrustedCommitmentTransaction this_arg_conv;
37067         this_arg_conv.inner = (void*)(this_arg & (~1));
37068         this_arg_conv.is_owned = false;
37069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37070         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
37071         uint32_t ret_ref = 0;
37072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37075         ret_ref = (uintptr_t)ret_var.inner;
37076         if (ret_var.is_owned) {
37077                 ret_ref |= 1;
37078         }
37079         return ret_ref;
37080 }
37081
37082 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
37083         LDKTrustedCommitmentTransaction this_arg_conv;
37084         this_arg_conv.inner = (void*)(this_arg & (~1));
37085         this_arg_conv.is_owned = false;
37086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37087         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
37088         uint32_t ret_ref = 0;
37089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37092         ret_ref = (uintptr_t)ret_var.inner;
37093         if (ret_var.is_owned) {
37094                 ret_ref |= 1;
37095         }
37096         return ret_ref;
37097 }
37098
37099 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
37100         LDKTrustedCommitmentTransaction this_arg_conv;
37101         this_arg_conv.inner = (void*)(this_arg & (~1));
37102         this_arg_conv.is_owned = false;
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37104         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
37105         return ret_conv;
37106 }
37107
37108 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) {
37109         LDKTrustedCommitmentTransaction this_arg_conv;
37110         this_arg_conv.inner = (void*)(this_arg & (~1));
37111         this_arg_conv.is_owned = false;
37112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37113         unsigned char htlc_base_key_arr[32];
37114         CHECK(htlc_base_key->arr_len == 32);
37115         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
37116         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
37117         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37118         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37119         channel_parameters_conv.is_owned = false;
37120         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37121         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
37122         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
37123         return (uint32_t)ret_conv;
37124 }
37125
37126 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) {
37127         LDKPublicKey broadcaster_payment_basepoint_ref;
37128         CHECK(broadcaster_payment_basepoint->arr_len == 33);
37129         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
37130         LDKPublicKey countersignatory_payment_basepoint_ref;
37131         CHECK(countersignatory_payment_basepoint->arr_len == 33);
37132         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
37133         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
37134         return ret_conv;
37135 }
37136
37137 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
37138         LDKInitFeatures a_conv;
37139         a_conv.inner = (void*)(a & (~1));
37140         a_conv.is_owned = false;
37141         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37142         LDKInitFeatures b_conv;
37143         b_conv.inner = (void*)(b & (~1));
37144         b_conv.is_owned = false;
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37146         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
37147         return ret_conv;
37148 }
37149
37150 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
37151         LDKNodeFeatures a_conv;
37152         a_conv.inner = (void*)(a & (~1));
37153         a_conv.is_owned = false;
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37155         LDKNodeFeatures b_conv;
37156         b_conv.inner = (void*)(b & (~1));
37157         b_conv.is_owned = false;
37158         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37159         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
37160         return ret_conv;
37161 }
37162
37163 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
37164         LDKChannelFeatures a_conv;
37165         a_conv.inner = (void*)(a & (~1));
37166         a_conv.is_owned = false;
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37168         LDKChannelFeatures b_conv;
37169         b_conv.inner = (void*)(b & (~1));
37170         b_conv.is_owned = false;
37171         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37172         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
37173         return ret_conv;
37174 }
37175
37176 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
37177         LDKInvoiceFeatures a_conv;
37178         a_conv.inner = (void*)(a & (~1));
37179         a_conv.is_owned = false;
37180         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37181         LDKInvoiceFeatures b_conv;
37182         b_conv.inner = (void*)(b & (~1));
37183         b_conv.is_owned = false;
37184         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37185         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
37186         return ret_conv;
37187 }
37188
37189 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
37190         LDKChannelTypeFeatures a_conv;
37191         a_conv.inner = (void*)(a & (~1));
37192         a_conv.is_owned = false;
37193         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37194         LDKChannelTypeFeatures b_conv;
37195         b_conv.inner = (void*)(b & (~1));
37196         b_conv.is_owned = false;
37197         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37198         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
37199         return ret_conv;
37200 }
37201
37202 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
37203         LDKInitFeatures ret_var = InitFeatures_clone(arg);
37204 uint32_t ret_ref = 0;
37205 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37206 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37207 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37208 ret_ref = (uintptr_t)ret_var.inner;
37209 if (ret_var.is_owned) {
37210         ret_ref |= 1;
37211 }
37212         return ret_ref;
37213 }
37214 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
37215         LDKInitFeatures arg_conv;
37216         arg_conv.inner = (void*)(arg & (~1));
37217         arg_conv.is_owned = false;
37218         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37219         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
37220         return ret_conv;
37221 }
37222
37223 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
37224         LDKInitFeatures orig_conv;
37225         orig_conv.inner = (void*)(orig & (~1));
37226         orig_conv.is_owned = false;
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37228         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
37229         uint32_t ret_ref = 0;
37230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37233         ret_ref = (uintptr_t)ret_var.inner;
37234         if (ret_var.is_owned) {
37235                 ret_ref |= 1;
37236         }
37237         return ret_ref;
37238 }
37239
37240 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
37241         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
37242 uint32_t ret_ref = 0;
37243 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37244 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37245 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37246 ret_ref = (uintptr_t)ret_var.inner;
37247 if (ret_var.is_owned) {
37248         ret_ref |= 1;
37249 }
37250         return ret_ref;
37251 }
37252 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
37253         LDKNodeFeatures arg_conv;
37254         arg_conv.inner = (void*)(arg & (~1));
37255         arg_conv.is_owned = false;
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37257         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
37258         return ret_conv;
37259 }
37260
37261 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
37262         LDKNodeFeatures orig_conv;
37263         orig_conv.inner = (void*)(orig & (~1));
37264         orig_conv.is_owned = false;
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37266         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
37267         uint32_t ret_ref = 0;
37268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37271         ret_ref = (uintptr_t)ret_var.inner;
37272         if (ret_var.is_owned) {
37273                 ret_ref |= 1;
37274         }
37275         return ret_ref;
37276 }
37277
37278 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
37279         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
37280 uint32_t ret_ref = 0;
37281 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37282 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37283 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37284 ret_ref = (uintptr_t)ret_var.inner;
37285 if (ret_var.is_owned) {
37286         ret_ref |= 1;
37287 }
37288         return ret_ref;
37289 }
37290 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
37291         LDKChannelFeatures arg_conv;
37292         arg_conv.inner = (void*)(arg & (~1));
37293         arg_conv.is_owned = false;
37294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37295         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
37296         return ret_conv;
37297 }
37298
37299 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
37300         LDKChannelFeatures orig_conv;
37301         orig_conv.inner = (void*)(orig & (~1));
37302         orig_conv.is_owned = false;
37303         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37304         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
37305         uint32_t ret_ref = 0;
37306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37309         ret_ref = (uintptr_t)ret_var.inner;
37310         if (ret_var.is_owned) {
37311                 ret_ref |= 1;
37312         }
37313         return ret_ref;
37314 }
37315
37316 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
37317         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
37318 uint32_t ret_ref = 0;
37319 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37320 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37321 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37322 ret_ref = (uintptr_t)ret_var.inner;
37323 if (ret_var.is_owned) {
37324         ret_ref |= 1;
37325 }
37326         return ret_ref;
37327 }
37328 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
37329         LDKInvoiceFeatures arg_conv;
37330         arg_conv.inner = (void*)(arg & (~1));
37331         arg_conv.is_owned = false;
37332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37333         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
37334         return ret_conv;
37335 }
37336
37337 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
37338         LDKInvoiceFeatures orig_conv;
37339         orig_conv.inner = (void*)(orig & (~1));
37340         orig_conv.is_owned = false;
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37342         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
37343         uint32_t ret_ref = 0;
37344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37347         ret_ref = (uintptr_t)ret_var.inner;
37348         if (ret_var.is_owned) {
37349                 ret_ref |= 1;
37350         }
37351         return ret_ref;
37352 }
37353
37354 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
37355         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
37356 uint32_t ret_ref = 0;
37357 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37358 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37359 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37360 ret_ref = (uintptr_t)ret_var.inner;
37361 if (ret_var.is_owned) {
37362         ret_ref |= 1;
37363 }
37364         return ret_ref;
37365 }
37366 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
37367         LDKChannelTypeFeatures arg_conv;
37368         arg_conv.inner = (void*)(arg & (~1));
37369         arg_conv.is_owned = false;
37370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37371         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
37372         return ret_conv;
37373 }
37374
37375 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
37376         LDKChannelTypeFeatures orig_conv;
37377         orig_conv.inner = (void*)(orig & (~1));
37378         orig_conv.is_owned = false;
37379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37380         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
37381         uint32_t ret_ref = 0;
37382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37385         ret_ref = (uintptr_t)ret_var.inner;
37386         if (ret_var.is_owned) {
37387                 ret_ref |= 1;
37388         }
37389         return ret_ref;
37390 }
37391
37392 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
37393         LDKInitFeatures this_obj_conv;
37394         this_obj_conv.inner = (void*)(this_obj & (~1));
37395         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37397         InitFeatures_free(this_obj_conv);
37398 }
37399
37400 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
37401         LDKNodeFeatures this_obj_conv;
37402         this_obj_conv.inner = (void*)(this_obj & (~1));
37403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37405         NodeFeatures_free(this_obj_conv);
37406 }
37407
37408 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
37409         LDKChannelFeatures this_obj_conv;
37410         this_obj_conv.inner = (void*)(this_obj & (~1));
37411         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37413         ChannelFeatures_free(this_obj_conv);
37414 }
37415
37416 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
37417         LDKInvoiceFeatures this_obj_conv;
37418         this_obj_conv.inner = (void*)(this_obj & (~1));
37419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37421         InvoiceFeatures_free(this_obj_conv);
37422 }
37423
37424 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
37425         LDKChannelTypeFeatures this_obj_conv;
37426         this_obj_conv.inner = (void*)(this_obj & (~1));
37427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37429         ChannelTypeFeatures_free(this_obj_conv);
37430 }
37431
37432 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
37433         LDKInitFeatures ret_var = InitFeatures_empty();
37434         uint32_t ret_ref = 0;
37435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37438         ret_ref = (uintptr_t)ret_var.inner;
37439         if (ret_var.is_owned) {
37440                 ret_ref |= 1;
37441         }
37442         return ret_ref;
37443 }
37444
37445 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
37446         LDKInitFeatures ret_var = InitFeatures_known();
37447         uint32_t ret_ref = 0;
37448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37451         ret_ref = (uintptr_t)ret_var.inner;
37452         if (ret_var.is_owned) {
37453                 ret_ref |= 1;
37454         }
37455         return ret_ref;
37456 }
37457
37458 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
37459         LDKInitFeatures this_arg_conv;
37460         this_arg_conv.inner = (void*)(this_arg & (~1));
37461         this_arg_conv.is_owned = false;
37462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37463         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
37464         return ret_conv;
37465 }
37466
37467 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
37468         LDKNodeFeatures ret_var = NodeFeatures_empty();
37469         uint32_t ret_ref = 0;
37470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37473         ret_ref = (uintptr_t)ret_var.inner;
37474         if (ret_var.is_owned) {
37475                 ret_ref |= 1;
37476         }
37477         return ret_ref;
37478 }
37479
37480 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
37481         LDKNodeFeatures ret_var = NodeFeatures_known();
37482         uint32_t ret_ref = 0;
37483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37486         ret_ref = (uintptr_t)ret_var.inner;
37487         if (ret_var.is_owned) {
37488                 ret_ref |= 1;
37489         }
37490         return ret_ref;
37491 }
37492
37493 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
37494         LDKNodeFeatures this_arg_conv;
37495         this_arg_conv.inner = (void*)(this_arg & (~1));
37496         this_arg_conv.is_owned = false;
37497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37498         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
37499         return ret_conv;
37500 }
37501
37502 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
37503         LDKChannelFeatures ret_var = ChannelFeatures_empty();
37504         uint32_t ret_ref = 0;
37505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37508         ret_ref = (uintptr_t)ret_var.inner;
37509         if (ret_var.is_owned) {
37510                 ret_ref |= 1;
37511         }
37512         return ret_ref;
37513 }
37514
37515 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
37516         LDKChannelFeatures ret_var = ChannelFeatures_known();
37517         uint32_t ret_ref = 0;
37518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37521         ret_ref = (uintptr_t)ret_var.inner;
37522         if (ret_var.is_owned) {
37523                 ret_ref |= 1;
37524         }
37525         return ret_ref;
37526 }
37527
37528 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
37529         LDKChannelFeatures this_arg_conv;
37530         this_arg_conv.inner = (void*)(this_arg & (~1));
37531         this_arg_conv.is_owned = false;
37532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37533         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
37534         return ret_conv;
37535 }
37536
37537 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
37538         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
37539         uint32_t ret_ref = 0;
37540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37543         ret_ref = (uintptr_t)ret_var.inner;
37544         if (ret_var.is_owned) {
37545                 ret_ref |= 1;
37546         }
37547         return ret_ref;
37548 }
37549
37550 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
37551         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
37552         uint32_t ret_ref = 0;
37553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37556         ret_ref = (uintptr_t)ret_var.inner;
37557         if (ret_var.is_owned) {
37558                 ret_ref |= 1;
37559         }
37560         return ret_ref;
37561 }
37562
37563 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
37564         LDKInvoiceFeatures this_arg_conv;
37565         this_arg_conv.inner = (void*)(this_arg & (~1));
37566         this_arg_conv.is_owned = false;
37567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37568         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
37569         return ret_conv;
37570 }
37571
37572 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
37573         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
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
37585 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
37586         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
37587         uint32_t ret_ref = 0;
37588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37591         ret_ref = (uintptr_t)ret_var.inner;
37592         if (ret_var.is_owned) {
37593                 ret_ref |= 1;
37594         }
37595         return ret_ref;
37596 }
37597
37598 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
37599         LDKChannelTypeFeatures this_arg_conv;
37600         this_arg_conv.inner = (void*)(this_arg & (~1));
37601         this_arg_conv.is_owned = false;
37602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37603         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
37604         return ret_conv;
37605 }
37606
37607 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
37608         LDKInitFeatures obj_conv;
37609         obj_conv.inner = (void*)(obj & (~1));
37610         obj_conv.is_owned = false;
37611         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37612         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
37613         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37614         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37615         CVec_u8Z_free(ret_var);
37616         return ret_arr;
37617 }
37618
37619 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
37620         LDKu8slice ser_ref;
37621         ser_ref.datalen = ser->arr_len;
37622         ser_ref.data = ser->elems;
37623         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
37624         *ret_conv = InitFeatures_read(ser_ref);
37625         FREE(ser);
37626         return (uint32_t)ret_conv;
37627 }
37628
37629 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
37630         LDKChannelFeatures obj_conv;
37631         obj_conv.inner = (void*)(obj & (~1));
37632         obj_conv.is_owned = false;
37633         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37634         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
37635         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37636         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37637         CVec_u8Z_free(ret_var);
37638         return ret_arr;
37639 }
37640
37641 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
37642         LDKu8slice ser_ref;
37643         ser_ref.datalen = ser->arr_len;
37644         ser_ref.data = ser->elems;
37645         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
37646         *ret_conv = ChannelFeatures_read(ser_ref);
37647         FREE(ser);
37648         return (uint32_t)ret_conv;
37649 }
37650
37651 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
37652         LDKNodeFeatures obj_conv;
37653         obj_conv.inner = (void*)(obj & (~1));
37654         obj_conv.is_owned = false;
37655         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37656         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
37657         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37658         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37659         CVec_u8Z_free(ret_var);
37660         return ret_arr;
37661 }
37662
37663 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
37664         LDKu8slice ser_ref;
37665         ser_ref.datalen = ser->arr_len;
37666         ser_ref.data = ser->elems;
37667         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
37668         *ret_conv = NodeFeatures_read(ser_ref);
37669         FREE(ser);
37670         return (uint32_t)ret_conv;
37671 }
37672
37673 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
37674         LDKInvoiceFeatures obj_conv;
37675         obj_conv.inner = (void*)(obj & (~1));
37676         obj_conv.is_owned = false;
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37678         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
37679         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37680         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37681         CVec_u8Z_free(ret_var);
37682         return ret_arr;
37683 }
37684
37685 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
37686         LDKu8slice ser_ref;
37687         ser_ref.datalen = ser->arr_len;
37688         ser_ref.data = ser->elems;
37689         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
37690         *ret_conv = InvoiceFeatures_read(ser_ref);
37691         FREE(ser);
37692         return (uint32_t)ret_conv;
37693 }
37694
37695 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
37696         LDKChannelTypeFeatures obj_conv;
37697         obj_conv.inner = (void*)(obj & (~1));
37698         obj_conv.is_owned = false;
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37700         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37701         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37702         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37703         CVec_u8Z_free(ret_var);
37704         return ret_arr;
37705 }
37706
37707 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37708         LDKu8slice ser_ref;
37709         ser_ref.datalen = ser->arr_len;
37710         ser_ref.data = ser->elems;
37711         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37712         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37713         FREE(ser);
37714         return (uint32_t)ret_conv;
37715 }
37716
37717 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37718         LDKInitFeatures this_arg_conv;
37719         this_arg_conv.inner = (void*)(this_arg & (~1));
37720         this_arg_conv.is_owned = false;
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37722         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37723 }
37724
37725 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37726         LDKInitFeatures this_arg_conv;
37727         this_arg_conv.inner = (void*)(this_arg & (~1));
37728         this_arg_conv.is_owned = false;
37729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37730         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37731 }
37732
37733 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
37734         LDKInitFeatures this_arg_conv;
37735         this_arg_conv.inner = (void*)(this_arg & (~1));
37736         this_arg_conv.is_owned = false;
37737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37738         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37739         return ret_conv;
37740 }
37741
37742 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37743         LDKNodeFeatures this_arg_conv;
37744         this_arg_conv.inner = (void*)(this_arg & (~1));
37745         this_arg_conv.is_owned = false;
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37747         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37748 }
37749
37750 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37751         LDKNodeFeatures this_arg_conv;
37752         this_arg_conv.inner = (void*)(this_arg & (~1));
37753         this_arg_conv.is_owned = false;
37754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37755         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37756 }
37757
37758 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
37759         LDKNodeFeatures this_arg_conv;
37760         this_arg_conv.inner = (void*)(this_arg & (~1));
37761         this_arg_conv.is_owned = false;
37762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37763         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37764         return ret_conv;
37765 }
37766
37767 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
37768         LDKInitFeatures this_arg_conv;
37769         this_arg_conv.inner = (void*)(this_arg & (~1));
37770         this_arg_conv.is_owned = false;
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37772         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37773         return ret_conv;
37774 }
37775
37776 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
37777         LDKNodeFeatures this_arg_conv;
37778         this_arg_conv.inner = (void*)(this_arg & (~1));
37779         this_arg_conv.is_owned = false;
37780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37781         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37782         return ret_conv;
37783 }
37784
37785 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
37786         LDKInitFeatures this_arg_conv;
37787         this_arg_conv.inner = (void*)(this_arg & (~1));
37788         this_arg_conv.is_owned = false;
37789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37790         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37791 }
37792
37793 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
37794         LDKInitFeatures this_arg_conv;
37795         this_arg_conv.inner = (void*)(this_arg & (~1));
37796         this_arg_conv.is_owned = false;
37797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37798         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37799 }
37800
37801 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
37802         LDKInitFeatures this_arg_conv;
37803         this_arg_conv.inner = (void*)(this_arg & (~1));
37804         this_arg_conv.is_owned = false;
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37806         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37807         return ret_conv;
37808 }
37809
37810 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37811         LDKInitFeatures this_arg_conv;
37812         this_arg_conv.inner = (void*)(this_arg & (~1));
37813         this_arg_conv.is_owned = false;
37814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37815         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37816 }
37817
37818 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37819         LDKInitFeatures this_arg_conv;
37820         this_arg_conv.inner = (void*)(this_arg & (~1));
37821         this_arg_conv.is_owned = false;
37822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37823         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37824 }
37825
37826 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37827         LDKInitFeatures this_arg_conv;
37828         this_arg_conv.inner = (void*)(this_arg & (~1));
37829         this_arg_conv.is_owned = false;
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37831         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37832         return ret_conv;
37833 }
37834
37835 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37836         LDKNodeFeatures this_arg_conv;
37837         this_arg_conv.inner = (void*)(this_arg & (~1));
37838         this_arg_conv.is_owned = false;
37839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37840         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37841 }
37842
37843 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37844         LDKNodeFeatures this_arg_conv;
37845         this_arg_conv.inner = (void*)(this_arg & (~1));
37846         this_arg_conv.is_owned = false;
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37848         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37849 }
37850
37851 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37852         LDKNodeFeatures this_arg_conv;
37853         this_arg_conv.inner = (void*)(this_arg & (~1));
37854         this_arg_conv.is_owned = false;
37855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37856         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37857         return ret_conv;
37858 }
37859
37860 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37861         LDKInitFeatures this_arg_conv;
37862         this_arg_conv.inner = (void*)(this_arg & (~1));
37863         this_arg_conv.is_owned = false;
37864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37865         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37866         return ret_conv;
37867 }
37868
37869 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37870         LDKNodeFeatures this_arg_conv;
37871         this_arg_conv.inner = (void*)(this_arg & (~1));
37872         this_arg_conv.is_owned = false;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37874         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37875         return ret_conv;
37876 }
37877
37878 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37879         LDKInitFeatures this_arg_conv;
37880         this_arg_conv.inner = (void*)(this_arg & (~1));
37881         this_arg_conv.is_owned = false;
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37883         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
37884 }
37885
37886 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
37887         LDKInitFeatures this_arg_conv;
37888         this_arg_conv.inner = (void*)(this_arg & (~1));
37889         this_arg_conv.is_owned = false;
37890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37891         InitFeatures_set_gossip_queries_required(&this_arg_conv);
37892 }
37893
37894 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
37895         LDKInitFeatures this_arg_conv;
37896         this_arg_conv.inner = (void*)(this_arg & (~1));
37897         this_arg_conv.is_owned = false;
37898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37899         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
37900         return ret_conv;
37901 }
37902
37903 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37904         LDKNodeFeatures this_arg_conv;
37905         this_arg_conv.inner = (void*)(this_arg & (~1));
37906         this_arg_conv.is_owned = false;
37907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37908         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
37909 }
37910
37911 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
37912         LDKNodeFeatures this_arg_conv;
37913         this_arg_conv.inner = (void*)(this_arg & (~1));
37914         this_arg_conv.is_owned = false;
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37916         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
37917 }
37918
37919 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
37920         LDKNodeFeatures this_arg_conv;
37921         this_arg_conv.inner = (void*)(this_arg & (~1));
37922         this_arg_conv.is_owned = false;
37923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37924         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
37925         return ret_conv;
37926 }
37927
37928 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
37929         LDKInitFeatures this_arg_conv;
37930         this_arg_conv.inner = (void*)(this_arg & (~1));
37931         this_arg_conv.is_owned = false;
37932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37933         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
37934         return ret_conv;
37935 }
37936
37937 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
37938         LDKNodeFeatures this_arg_conv;
37939         this_arg_conv.inner = (void*)(this_arg & (~1));
37940         this_arg_conv.is_owned = false;
37941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37942         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
37943         return ret_conv;
37944 }
37945
37946 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37947         LDKInitFeatures this_arg_conv;
37948         this_arg_conv.inner = (void*)(this_arg & (~1));
37949         this_arg_conv.is_owned = false;
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37951         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
37952 }
37953
37954 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37955         LDKInitFeatures this_arg_conv;
37956         this_arg_conv.inner = (void*)(this_arg & (~1));
37957         this_arg_conv.is_owned = false;
37958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37959         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
37960 }
37961
37962 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
37963         LDKInitFeatures this_arg_conv;
37964         this_arg_conv.inner = (void*)(this_arg & (~1));
37965         this_arg_conv.is_owned = false;
37966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37967         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
37968         return ret_conv;
37969 }
37970
37971 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37972         LDKNodeFeatures this_arg_conv;
37973         this_arg_conv.inner = (void*)(this_arg & (~1));
37974         this_arg_conv.is_owned = false;
37975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37976         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
37977 }
37978
37979 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37980         LDKNodeFeatures this_arg_conv;
37981         this_arg_conv.inner = (void*)(this_arg & (~1));
37982         this_arg_conv.is_owned = false;
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37984         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
37985 }
37986
37987 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
37988         LDKNodeFeatures this_arg_conv;
37989         this_arg_conv.inner = (void*)(this_arg & (~1));
37990         this_arg_conv.is_owned = false;
37991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37992         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
37993         return ret_conv;
37994 }
37995
37996 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37997         LDKInvoiceFeatures this_arg_conv;
37998         this_arg_conv.inner = (void*)(this_arg & (~1));
37999         this_arg_conv.is_owned = false;
38000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38001         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
38002 }
38003
38004 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38005         LDKInvoiceFeatures this_arg_conv;
38006         this_arg_conv.inner = (void*)(this_arg & (~1));
38007         this_arg_conv.is_owned = false;
38008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38009         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
38010 }
38011
38012 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
38013         LDKInvoiceFeatures this_arg_conv;
38014         this_arg_conv.inner = (void*)(this_arg & (~1));
38015         this_arg_conv.is_owned = false;
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38017         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
38018         return ret_conv;
38019 }
38020
38021 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
38022         LDKInitFeatures this_arg_conv;
38023         this_arg_conv.inner = (void*)(this_arg & (~1));
38024         this_arg_conv.is_owned = false;
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38026         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
38027         return ret_conv;
38028 }
38029
38030 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
38031         LDKNodeFeatures this_arg_conv;
38032         this_arg_conv.inner = (void*)(this_arg & (~1));
38033         this_arg_conv.is_owned = false;
38034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38035         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
38036         return ret_conv;
38037 }
38038
38039 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
38040         LDKInvoiceFeatures this_arg_conv;
38041         this_arg_conv.inner = (void*)(this_arg & (~1));
38042         this_arg_conv.is_owned = false;
38043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38044         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
38045         return ret_conv;
38046 }
38047
38048 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38049         LDKInitFeatures this_arg_conv;
38050         this_arg_conv.inner = (void*)(this_arg & (~1));
38051         this_arg_conv.is_owned = false;
38052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38053         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
38054 }
38055
38056 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
38057         LDKInitFeatures this_arg_conv;
38058         this_arg_conv.inner = (void*)(this_arg & (~1));
38059         this_arg_conv.is_owned = false;
38060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38061         InitFeatures_set_static_remote_key_required(&this_arg_conv);
38062 }
38063
38064 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
38065         LDKInitFeatures this_arg_conv;
38066         this_arg_conv.inner = (void*)(this_arg & (~1));
38067         this_arg_conv.is_owned = false;
38068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38069         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
38070         return ret_conv;
38071 }
38072
38073 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38074         LDKNodeFeatures this_arg_conv;
38075         this_arg_conv.inner = (void*)(this_arg & (~1));
38076         this_arg_conv.is_owned = false;
38077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38078         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
38079 }
38080
38081 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38082         LDKNodeFeatures this_arg_conv;
38083         this_arg_conv.inner = (void*)(this_arg & (~1));
38084         this_arg_conv.is_owned = false;
38085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38086         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
38087 }
38088
38089 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
38090         LDKNodeFeatures this_arg_conv;
38091         this_arg_conv.inner = (void*)(this_arg & (~1));
38092         this_arg_conv.is_owned = false;
38093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38094         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
38095         return ret_conv;
38096 }
38097
38098 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38099         LDKChannelTypeFeatures this_arg_conv;
38100         this_arg_conv.inner = (void*)(this_arg & (~1));
38101         this_arg_conv.is_owned = false;
38102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38103         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
38104 }
38105
38106 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38107         LDKChannelTypeFeatures this_arg_conv;
38108         this_arg_conv.inner = (void*)(this_arg & (~1));
38109         this_arg_conv.is_owned = false;
38110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38111         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
38112 }
38113
38114 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
38115         LDKChannelTypeFeatures this_arg_conv;
38116         this_arg_conv.inner = (void*)(this_arg & (~1));
38117         this_arg_conv.is_owned = false;
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38119         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
38120         return ret_conv;
38121 }
38122
38123 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
38124         LDKInitFeatures this_arg_conv;
38125         this_arg_conv.inner = (void*)(this_arg & (~1));
38126         this_arg_conv.is_owned = false;
38127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38128         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
38129         return ret_conv;
38130 }
38131
38132 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
38133         LDKNodeFeatures this_arg_conv;
38134         this_arg_conv.inner = (void*)(this_arg & (~1));
38135         this_arg_conv.is_owned = false;
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38137         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
38138         return ret_conv;
38139 }
38140
38141 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
38142         LDKChannelTypeFeatures this_arg_conv;
38143         this_arg_conv.inner = (void*)(this_arg & (~1));
38144         this_arg_conv.is_owned = false;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38146         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
38147         return ret_conv;
38148 }
38149
38150 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
38151         LDKInitFeatures this_arg_conv;
38152         this_arg_conv.inner = (void*)(this_arg & (~1));
38153         this_arg_conv.is_owned = false;
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38155         InitFeatures_set_payment_secret_optional(&this_arg_conv);
38156 }
38157
38158 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
38159         LDKInitFeatures this_arg_conv;
38160         this_arg_conv.inner = (void*)(this_arg & (~1));
38161         this_arg_conv.is_owned = false;
38162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38163         InitFeatures_set_payment_secret_required(&this_arg_conv);
38164 }
38165
38166 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
38167         LDKInitFeatures this_arg_conv;
38168         this_arg_conv.inner = (void*)(this_arg & (~1));
38169         this_arg_conv.is_owned = false;
38170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38171         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
38172         return ret_conv;
38173 }
38174
38175 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
38176         LDKNodeFeatures this_arg_conv;
38177         this_arg_conv.inner = (void*)(this_arg & (~1));
38178         this_arg_conv.is_owned = false;
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38180         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
38181 }
38182
38183 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
38184         LDKNodeFeatures this_arg_conv;
38185         this_arg_conv.inner = (void*)(this_arg & (~1));
38186         this_arg_conv.is_owned = false;
38187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38188         NodeFeatures_set_payment_secret_required(&this_arg_conv);
38189 }
38190
38191 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
38192         LDKNodeFeatures this_arg_conv;
38193         this_arg_conv.inner = (void*)(this_arg & (~1));
38194         this_arg_conv.is_owned = false;
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38196         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
38197         return ret_conv;
38198 }
38199
38200 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
38201         LDKInvoiceFeatures this_arg_conv;
38202         this_arg_conv.inner = (void*)(this_arg & (~1));
38203         this_arg_conv.is_owned = false;
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38205         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
38206 }
38207
38208 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
38209         LDKInvoiceFeatures this_arg_conv;
38210         this_arg_conv.inner = (void*)(this_arg & (~1));
38211         this_arg_conv.is_owned = false;
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38213         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
38214 }
38215
38216 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
38217         LDKInvoiceFeatures this_arg_conv;
38218         this_arg_conv.inner = (void*)(this_arg & (~1));
38219         this_arg_conv.is_owned = false;
38220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38221         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
38222         return ret_conv;
38223 }
38224
38225 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
38226         LDKInitFeatures this_arg_conv;
38227         this_arg_conv.inner = (void*)(this_arg & (~1));
38228         this_arg_conv.is_owned = false;
38229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38230         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
38231         return ret_conv;
38232 }
38233
38234 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
38235         LDKNodeFeatures this_arg_conv;
38236         this_arg_conv.inner = (void*)(this_arg & (~1));
38237         this_arg_conv.is_owned = false;
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38239         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
38240         return ret_conv;
38241 }
38242
38243 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
38244         LDKInvoiceFeatures this_arg_conv;
38245         this_arg_conv.inner = (void*)(this_arg & (~1));
38246         this_arg_conv.is_owned = false;
38247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38248         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
38249         return ret_conv;
38250 }
38251
38252 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38253         LDKInitFeatures this_arg_conv;
38254         this_arg_conv.inner = (void*)(this_arg & (~1));
38255         this_arg_conv.is_owned = false;
38256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38257         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
38258 }
38259
38260 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
38261         LDKInitFeatures this_arg_conv;
38262         this_arg_conv.inner = (void*)(this_arg & (~1));
38263         this_arg_conv.is_owned = false;
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38265         InitFeatures_set_basic_mpp_required(&this_arg_conv);
38266 }
38267
38268 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
38269         LDKInitFeatures this_arg_conv;
38270         this_arg_conv.inner = (void*)(this_arg & (~1));
38271         this_arg_conv.is_owned = false;
38272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38273         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
38274         return ret_conv;
38275 }
38276
38277 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38278         LDKNodeFeatures this_arg_conv;
38279         this_arg_conv.inner = (void*)(this_arg & (~1));
38280         this_arg_conv.is_owned = false;
38281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38282         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
38283 }
38284
38285 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
38286         LDKNodeFeatures this_arg_conv;
38287         this_arg_conv.inner = (void*)(this_arg & (~1));
38288         this_arg_conv.is_owned = false;
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38290         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
38291 }
38292
38293 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
38294         LDKNodeFeatures this_arg_conv;
38295         this_arg_conv.inner = (void*)(this_arg & (~1));
38296         this_arg_conv.is_owned = false;
38297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38298         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
38299         return ret_conv;
38300 }
38301
38302 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38303         LDKInvoiceFeatures this_arg_conv;
38304         this_arg_conv.inner = (void*)(this_arg & (~1));
38305         this_arg_conv.is_owned = false;
38306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38307         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
38308 }
38309
38310 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
38311         LDKInvoiceFeatures this_arg_conv;
38312         this_arg_conv.inner = (void*)(this_arg & (~1));
38313         this_arg_conv.is_owned = false;
38314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38315         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
38316 }
38317
38318 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
38319         LDKInvoiceFeatures this_arg_conv;
38320         this_arg_conv.inner = (void*)(this_arg & (~1));
38321         this_arg_conv.is_owned = false;
38322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38323         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
38324         return ret_conv;
38325 }
38326
38327 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
38328         LDKInitFeatures this_arg_conv;
38329         this_arg_conv.inner = (void*)(this_arg & (~1));
38330         this_arg_conv.is_owned = false;
38331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38332         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
38333         return ret_conv;
38334 }
38335
38336 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
38337         LDKNodeFeatures this_arg_conv;
38338         this_arg_conv.inner = (void*)(this_arg & (~1));
38339         this_arg_conv.is_owned = false;
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38341         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
38342         return ret_conv;
38343 }
38344
38345 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
38346         LDKInvoiceFeatures this_arg_conv;
38347         this_arg_conv.inner = (void*)(this_arg & (~1));
38348         this_arg_conv.is_owned = false;
38349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38350         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
38351         return ret_conv;
38352 }
38353
38354 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
38355         LDKInitFeatures this_arg_conv;
38356         this_arg_conv.inner = (void*)(this_arg & (~1));
38357         this_arg_conv.is_owned = false;
38358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38359         InitFeatures_set_wumbo_optional(&this_arg_conv);
38360 }
38361
38362 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
38363         LDKInitFeatures this_arg_conv;
38364         this_arg_conv.inner = (void*)(this_arg & (~1));
38365         this_arg_conv.is_owned = false;
38366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38367         InitFeatures_set_wumbo_required(&this_arg_conv);
38368 }
38369
38370 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
38371         LDKInitFeatures this_arg_conv;
38372         this_arg_conv.inner = (void*)(this_arg & (~1));
38373         this_arg_conv.is_owned = false;
38374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38375         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
38376         return ret_conv;
38377 }
38378
38379 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
38380         LDKNodeFeatures this_arg_conv;
38381         this_arg_conv.inner = (void*)(this_arg & (~1));
38382         this_arg_conv.is_owned = false;
38383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38384         NodeFeatures_set_wumbo_optional(&this_arg_conv);
38385 }
38386
38387 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
38388         LDKNodeFeatures this_arg_conv;
38389         this_arg_conv.inner = (void*)(this_arg & (~1));
38390         this_arg_conv.is_owned = false;
38391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38392         NodeFeatures_set_wumbo_required(&this_arg_conv);
38393 }
38394
38395 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
38396         LDKNodeFeatures this_arg_conv;
38397         this_arg_conv.inner = (void*)(this_arg & (~1));
38398         this_arg_conv.is_owned = false;
38399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38400         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
38401         return ret_conv;
38402 }
38403
38404 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
38405         LDKInitFeatures this_arg_conv;
38406         this_arg_conv.inner = (void*)(this_arg & (~1));
38407         this_arg_conv.is_owned = false;
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38409         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
38410         return ret_conv;
38411 }
38412
38413 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
38414         LDKNodeFeatures this_arg_conv;
38415         this_arg_conv.inner = (void*)(this_arg & (~1));
38416         this_arg_conv.is_owned = false;
38417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38418         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
38419         return ret_conv;
38420 }
38421
38422 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38423         LDKInitFeatures this_arg_conv;
38424         this_arg_conv.inner = (void*)(this_arg & (~1));
38425         this_arg_conv.is_owned = false;
38426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38427         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38428 }
38429
38430 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38431         LDKInitFeatures this_arg_conv;
38432         this_arg_conv.inner = (void*)(this_arg & (~1));
38433         this_arg_conv.is_owned = false;
38434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38435         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38436 }
38437
38438 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38439         LDKInitFeatures this_arg_conv;
38440         this_arg_conv.inner = (void*)(this_arg & (~1));
38441         this_arg_conv.is_owned = false;
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38443         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38444         return ret_conv;
38445 }
38446
38447 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38448         LDKNodeFeatures this_arg_conv;
38449         this_arg_conv.inner = (void*)(this_arg & (~1));
38450         this_arg_conv.is_owned = false;
38451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38452         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38453 }
38454
38455 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38456         LDKNodeFeatures this_arg_conv;
38457         this_arg_conv.inner = (void*)(this_arg & (~1));
38458         this_arg_conv.is_owned = false;
38459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38460         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38461 }
38462
38463 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38464         LDKNodeFeatures this_arg_conv;
38465         this_arg_conv.inner = (void*)(this_arg & (~1));
38466         this_arg_conv.is_owned = false;
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38468         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38469         return ret_conv;
38470 }
38471
38472 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38473         LDKInitFeatures this_arg_conv;
38474         this_arg_conv.inner = (void*)(this_arg & (~1));
38475         this_arg_conv.is_owned = false;
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38477         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38478         return ret_conv;
38479 }
38480
38481 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38482         LDKNodeFeatures this_arg_conv;
38483         this_arg_conv.inner = (void*)(this_arg & (~1));
38484         this_arg_conv.is_owned = false;
38485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38486         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38487         return ret_conv;
38488 }
38489
38490 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
38491         LDKInitFeatures this_arg_conv;
38492         this_arg_conv.inner = (void*)(this_arg & (~1));
38493         this_arg_conv.is_owned = false;
38494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38495         InitFeatures_set_channel_type_optional(&this_arg_conv);
38496 }
38497
38498 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
38499         LDKInitFeatures this_arg_conv;
38500         this_arg_conv.inner = (void*)(this_arg & (~1));
38501         this_arg_conv.is_owned = false;
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38503         InitFeatures_set_channel_type_required(&this_arg_conv);
38504 }
38505
38506 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint32_t this_arg) {
38507         LDKInitFeatures this_arg_conv;
38508         this_arg_conv.inner = (void*)(this_arg & (~1));
38509         this_arg_conv.is_owned = false;
38510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38511         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
38512         return ret_conv;
38513 }
38514
38515 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
38516         LDKNodeFeatures this_arg_conv;
38517         this_arg_conv.inner = (void*)(this_arg & (~1));
38518         this_arg_conv.is_owned = false;
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38520         NodeFeatures_set_channel_type_optional(&this_arg_conv);
38521 }
38522
38523 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
38524         LDKNodeFeatures this_arg_conv;
38525         this_arg_conv.inner = (void*)(this_arg & (~1));
38526         this_arg_conv.is_owned = false;
38527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38528         NodeFeatures_set_channel_type_required(&this_arg_conv);
38529 }
38530
38531 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint32_t this_arg) {
38532         LDKNodeFeatures this_arg_conv;
38533         this_arg_conv.inner = (void*)(this_arg & (~1));
38534         this_arg_conv.is_owned = false;
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38536         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
38537         return ret_conv;
38538 }
38539
38540 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
38541         LDKInitFeatures this_arg_conv;
38542         this_arg_conv.inner = (void*)(this_arg & (~1));
38543         this_arg_conv.is_owned = false;
38544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38545         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
38546         return ret_conv;
38547 }
38548
38549 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
38550         LDKNodeFeatures this_arg_conv;
38551         this_arg_conv.inner = (void*)(this_arg & (~1));
38552         this_arg_conv.is_owned = false;
38553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38554         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
38555         return ret_conv;
38556 }
38557
38558 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38559         LDKInitFeatures this_arg_conv;
38560         this_arg_conv.inner = (void*)(this_arg & (~1));
38561         this_arg_conv.is_owned = false;
38562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38563         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
38564 }
38565
38566 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
38567         LDKInitFeatures this_arg_conv;
38568         this_arg_conv.inner = (void*)(this_arg & (~1));
38569         this_arg_conv.is_owned = false;
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38571         InitFeatures_set_scid_privacy_required(&this_arg_conv);
38572 }
38573
38574 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint32_t this_arg) {
38575         LDKInitFeatures this_arg_conv;
38576         this_arg_conv.inner = (void*)(this_arg & (~1));
38577         this_arg_conv.is_owned = false;
38578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38579         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
38580         return ret_conv;
38581 }
38582
38583 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38584         LDKNodeFeatures this_arg_conv;
38585         this_arg_conv.inner = (void*)(this_arg & (~1));
38586         this_arg_conv.is_owned = false;
38587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38588         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
38589 }
38590
38591 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38592         LDKNodeFeatures this_arg_conv;
38593         this_arg_conv.inner = (void*)(this_arg & (~1));
38594         this_arg_conv.is_owned = false;
38595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38596         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
38597 }
38598
38599 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint32_t this_arg) {
38600         LDKNodeFeatures this_arg_conv;
38601         this_arg_conv.inner = (void*)(this_arg & (~1));
38602         this_arg_conv.is_owned = false;
38603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38604         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
38605         return ret_conv;
38606 }
38607
38608 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38609         LDKChannelTypeFeatures this_arg_conv;
38610         this_arg_conv.inner = (void*)(this_arg & (~1));
38611         this_arg_conv.is_owned = false;
38612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38613         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
38614 }
38615
38616 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38617         LDKChannelTypeFeatures this_arg_conv;
38618         this_arg_conv.inner = (void*)(this_arg & (~1));
38619         this_arg_conv.is_owned = false;
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38621         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
38622 }
38623
38624 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
38625         LDKChannelTypeFeatures this_arg_conv;
38626         this_arg_conv.inner = (void*)(this_arg & (~1));
38627         this_arg_conv.is_owned = false;
38628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38629         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
38630         return ret_conv;
38631 }
38632
38633 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
38634         LDKInitFeatures this_arg_conv;
38635         this_arg_conv.inner = (void*)(this_arg & (~1));
38636         this_arg_conv.is_owned = false;
38637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38638         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
38639         return ret_conv;
38640 }
38641
38642 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
38643         LDKNodeFeatures this_arg_conv;
38644         this_arg_conv.inner = (void*)(this_arg & (~1));
38645         this_arg_conv.is_owned = false;
38646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38647         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
38648         return ret_conv;
38649 }
38650
38651 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
38652         LDKChannelTypeFeatures this_arg_conv;
38653         this_arg_conv.inner = (void*)(this_arg & (~1));
38654         this_arg_conv.is_owned = false;
38655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38656         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
38657         return ret_conv;
38658 }
38659
38660 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
38661         LDKInitFeatures this_arg_conv;
38662         this_arg_conv.inner = (void*)(this_arg & (~1));
38663         this_arg_conv.is_owned = false;
38664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38665         InitFeatures_set_zero_conf_optional(&this_arg_conv);
38666 }
38667
38668 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
38669         LDKInitFeatures this_arg_conv;
38670         this_arg_conv.inner = (void*)(this_arg & (~1));
38671         this_arg_conv.is_owned = false;
38672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38673         InitFeatures_set_zero_conf_required(&this_arg_conv);
38674 }
38675
38676 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
38677         LDKInitFeatures this_arg_conv;
38678         this_arg_conv.inner = (void*)(this_arg & (~1));
38679         this_arg_conv.is_owned = false;
38680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38681         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
38682         return ret_conv;
38683 }
38684
38685 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38686         LDKNodeFeatures this_arg_conv;
38687         this_arg_conv.inner = (void*)(this_arg & (~1));
38688         this_arg_conv.is_owned = false;
38689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38690         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
38691 }
38692
38693 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
38694         LDKNodeFeatures this_arg_conv;
38695         this_arg_conv.inner = (void*)(this_arg & (~1));
38696         this_arg_conv.is_owned = false;
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38698         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38699 }
38700
38701 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
38702         LDKNodeFeatures this_arg_conv;
38703         this_arg_conv.inner = (void*)(this_arg & (~1));
38704         this_arg_conv.is_owned = false;
38705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38706         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38707         return ret_conv;
38708 }
38709
38710 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38711         LDKChannelTypeFeatures this_arg_conv;
38712         this_arg_conv.inner = (void*)(this_arg & (~1));
38713         this_arg_conv.is_owned = false;
38714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38715         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38716 }
38717
38718 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
38719         LDKChannelTypeFeatures this_arg_conv;
38720         this_arg_conv.inner = (void*)(this_arg & (~1));
38721         this_arg_conv.is_owned = false;
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38723         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38724 }
38725
38726 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
38727         LDKChannelTypeFeatures this_arg_conv;
38728         this_arg_conv.inner = (void*)(this_arg & (~1));
38729         this_arg_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38731         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
38732         return ret_conv;
38733 }
38734
38735 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint32_t this_arg) {
38736         LDKInitFeatures this_arg_conv;
38737         this_arg_conv.inner = (void*)(this_arg & (~1));
38738         this_arg_conv.is_owned = false;
38739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38740         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
38741         return ret_conv;
38742 }
38743
38744 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
38745         LDKNodeFeatures this_arg_conv;
38746         this_arg_conv.inner = (void*)(this_arg & (~1));
38747         this_arg_conv.is_owned = false;
38748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38749         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38750         return ret_conv;
38751 }
38752
38753 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
38754         LDKChannelTypeFeatures this_arg_conv;
38755         this_arg_conv.inner = (void*)(this_arg & (~1));
38756         this_arg_conv.is_owned = false;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38758         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38759         return ret_conv;
38760 }
38761
38762 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
38763         LDKNodeFeatures this_arg_conv;
38764         this_arg_conv.inner = (void*)(this_arg & (~1));
38765         this_arg_conv.is_owned = false;
38766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38767         NodeFeatures_set_keysend_optional(&this_arg_conv);
38768 }
38769
38770 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
38771         LDKNodeFeatures this_arg_conv;
38772         this_arg_conv.inner = (void*)(this_arg & (~1));
38773         this_arg_conv.is_owned = false;
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38775         NodeFeatures_set_keysend_required(&this_arg_conv);
38776 }
38777
38778 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
38779         LDKNodeFeatures this_arg_conv;
38780         this_arg_conv.inner = (void*)(this_arg & (~1));
38781         this_arg_conv.is_owned = false;
38782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38783         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38784         return ret_conv;
38785 }
38786
38787 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
38788         LDKNodeFeatures this_arg_conv;
38789         this_arg_conv.inner = (void*)(this_arg & (~1));
38790         this_arg_conv.is_owned = false;
38791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38792         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38793         return ret_conv;
38794 }
38795
38796 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
38797         LDKShutdownScript this_obj_conv;
38798         this_obj_conv.inner = (void*)(this_obj & (~1));
38799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38801         ShutdownScript_free(this_obj_conv);
38802 }
38803
38804 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38805         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38806 uint32_t ret_ref = 0;
38807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38810 ret_ref = (uintptr_t)ret_var.inner;
38811 if (ret_var.is_owned) {
38812         ret_ref |= 1;
38813 }
38814         return ret_ref;
38815 }
38816 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
38817         LDKShutdownScript arg_conv;
38818         arg_conv.inner = (void*)(arg & (~1));
38819         arg_conv.is_owned = false;
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38821         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38822         return ret_conv;
38823 }
38824
38825 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
38826         LDKShutdownScript orig_conv;
38827         orig_conv.inner = (void*)(orig & (~1));
38828         orig_conv.is_owned = false;
38829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38830         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38831         uint32_t ret_ref = 0;
38832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38835         ret_ref = (uintptr_t)ret_var.inner;
38836         if (ret_var.is_owned) {
38837                 ret_ref |= 1;
38838         }
38839         return ret_ref;
38840 }
38841
38842 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
38843         LDKInvalidShutdownScript this_obj_conv;
38844         this_obj_conv.inner = (void*)(this_obj & (~1));
38845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38847         InvalidShutdownScript_free(this_obj_conv);
38848 }
38849
38850 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
38851         LDKInvalidShutdownScript this_ptr_conv;
38852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38853         this_ptr_conv.is_owned = false;
38854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38855         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38856         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38857         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38858         return ret_arr;
38859 }
38860
38861 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
38862         LDKInvalidShutdownScript this_ptr_conv;
38863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38864         this_ptr_conv.is_owned = false;
38865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38866         LDKCVec_u8Z val_ref;
38867         val_ref.datalen = val->arr_len;
38868         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38869         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38870         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38871 }
38872
38873 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
38874         LDKCVec_u8Z script_arg_ref;
38875         script_arg_ref.datalen = script_arg->arr_len;
38876         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38877         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
38878         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
38879         uint32_t ret_ref = 0;
38880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38883         ret_ref = (uintptr_t)ret_var.inner;
38884         if (ret_var.is_owned) {
38885                 ret_ref |= 1;
38886         }
38887         return ret_ref;
38888 }
38889
38890 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
38891         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
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 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
38903         LDKInvalidShutdownScript arg_conv;
38904         arg_conv.inner = (void*)(arg & (~1));
38905         arg_conv.is_owned = false;
38906         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38907         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
38908         return ret_conv;
38909 }
38910
38911 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
38912         LDKInvalidShutdownScript orig_conv;
38913         orig_conv.inner = (void*)(orig & (~1));
38914         orig_conv.is_owned = false;
38915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38916         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
38917         uint32_t ret_ref = 0;
38918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38921         ret_ref = (uintptr_t)ret_var.inner;
38922         if (ret_var.is_owned) {
38923                 ret_ref |= 1;
38924         }
38925         return ret_ref;
38926 }
38927
38928 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
38929         LDKShutdownScript obj_conv;
38930         obj_conv.inner = (void*)(obj & (~1));
38931         obj_conv.is_owned = false;
38932         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38933         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
38934         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38935         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38936         CVec_u8Z_free(ret_var);
38937         return ret_arr;
38938 }
38939
38940 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
38941         LDKu8slice ser_ref;
38942         ser_ref.datalen = ser->arr_len;
38943         ser_ref.data = ser->elems;
38944         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
38945         *ret_conv = ShutdownScript_read(ser_ref);
38946         FREE(ser);
38947         return (uint32_t)ret_conv;
38948 }
38949
38950 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
38951         unsigned char pubkey_hash_arr[20];
38952         CHECK(pubkey_hash->arr_len == 20);
38953         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
38954         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
38955         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
38956         uint32_t ret_ref = 0;
38957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38960         ret_ref = (uintptr_t)ret_var.inner;
38961         if (ret_var.is_owned) {
38962                 ret_ref |= 1;
38963         }
38964         return ret_ref;
38965 }
38966
38967 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
38968         unsigned char script_hash_arr[32];
38969         CHECK(script_hash->arr_len == 32);
38970         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
38971         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
38972         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
38973         uint32_t ret_ref = 0;
38974         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38975         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38977         ret_ref = (uintptr_t)ret_var.inner;
38978         if (ret_var.is_owned) {
38979                 ret_ref |= 1;
38980         }
38981         return ret_ref;
38982 }
38983
38984 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
38985         
38986         LDKu8slice program_ref;
38987         program_ref.datalen = program->arr_len;
38988         program_ref.data = program->elems;
38989         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
38990         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
38991         FREE(program);
38992         return (uint32_t)ret_conv;
38993 }
38994
38995 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
38996         LDKShutdownScript this_arg_conv;
38997         this_arg_conv.inner = (void*)(this_arg & (~1));
38998         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39000         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39001         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39002         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39003         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39004         CVec_u8Z_free(ret_var);
39005         return ret_arr;
39006 }
39007
39008 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
39009         LDKShutdownScript this_arg_conv;
39010         this_arg_conv.inner = (void*)(this_arg & (~1));
39011         this_arg_conv.is_owned = false;
39012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39013         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39014         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
39015         return ret_arr;
39016 }
39017
39018 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
39019         LDKShutdownScript this_arg_conv;
39020         this_arg_conv.inner = (void*)(this_arg & (~1));
39021         this_arg_conv.is_owned = false;
39022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39023         LDKInitFeatures features_conv;
39024         features_conv.inner = (void*)(features & (~1));
39025         features_conv.is_owned = false;
39026         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39027         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39028         return ret_conv;
39029 }
39030
39031 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
39032         if ((this_ptr & 1) != 0) return;
39033         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39034         CHECK_ACCESS(this_ptr_ptr);
39035         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39036         FREE((void*)this_ptr);
39037         CustomMessageReader_free(this_ptr_conv);
39038 }
39039
39040 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39041         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39042         *ret_ret = Type_clone(arg);
39043         return (uint32_t)ret_ret;
39044 }
39045 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
39046         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39047         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39048         LDKType* arg_conv = (LDKType*)arg_ptr;
39049         uint32_t ret_conv = Type_clone_ptr(arg_conv);
39050         return ret_conv;
39051 }
39052
39053 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
39054         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39055         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39056         LDKType* orig_conv = (LDKType*)orig_ptr;
39057         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39058         *ret_ret = Type_clone(orig_conv);
39059         return (uint32_t)ret_ret;
39060 }
39061
39062 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
39063         if ((this_ptr & 1) != 0) return;
39064         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39065         CHECK_ACCESS(this_ptr_ptr);
39066         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39067         FREE((void*)this_ptr);
39068         Type_free(this_ptr_conv);
39069 }
39070
39071 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
39072         LDKNodeId this_obj_conv;
39073         this_obj_conv.inner = (void*)(this_obj & (~1));
39074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39076         NodeId_free(this_obj_conv);
39077 }
39078
39079 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39080         LDKNodeId ret_var = NodeId_clone(arg);
39081 uint32_t ret_ref = 0;
39082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39085 ret_ref = (uintptr_t)ret_var.inner;
39086 if (ret_var.is_owned) {
39087         ret_ref |= 1;
39088 }
39089         return ret_ref;
39090 }
39091 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
39092         LDKNodeId arg_conv;
39093         arg_conv.inner = (void*)(arg & (~1));
39094         arg_conv.is_owned = false;
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39096         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
39097         return ret_conv;
39098 }
39099
39100 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
39101         LDKNodeId orig_conv;
39102         orig_conv.inner = (void*)(orig & (~1));
39103         orig_conv.is_owned = false;
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39105         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39106         uint32_t ret_ref = 0;
39107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39110         ret_ref = (uintptr_t)ret_var.inner;
39111         if (ret_var.is_owned) {
39112                 ret_ref |= 1;
39113         }
39114         return ret_ref;
39115 }
39116
39117 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
39118         LDKPublicKey pubkey_ref;
39119         CHECK(pubkey->arr_len == 33);
39120         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
39121         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39122         uint32_t ret_ref = 0;
39123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39126         ret_ref = (uintptr_t)ret_var.inner;
39127         if (ret_var.is_owned) {
39128                 ret_ref |= 1;
39129         }
39130         return ret_ref;
39131 }
39132
39133 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
39134         LDKNodeId this_arg_conv;
39135         this_arg_conv.inner = (void*)(this_arg & (~1));
39136         this_arg_conv.is_owned = false;
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39138         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39139         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39140         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39141         return ret_arr;
39142 }
39143
39144 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
39145         LDKNodeId o_conv;
39146         o_conv.inner = (void*)(o & (~1));
39147         o_conv.is_owned = false;
39148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39149         int64_t ret_conv = NodeId_hash(&o_conv);
39150         return ret_conv;
39151 }
39152
39153 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
39154         LDKNodeId obj_conv;
39155         obj_conv.inner = (void*)(obj & (~1));
39156         obj_conv.is_owned = false;
39157         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39158         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39159         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39160         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39161         CVec_u8Z_free(ret_var);
39162         return ret_arr;
39163 }
39164
39165 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
39166         LDKu8slice ser_ref;
39167         ser_ref.datalen = ser->arr_len;
39168         ser_ref.data = ser->elems;
39169         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39170         *ret_conv = NodeId_read(ser_ref);
39171         FREE(ser);
39172         return (uint32_t)ret_conv;
39173 }
39174
39175 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
39176         LDKNetworkGraph this_obj_conv;
39177         this_obj_conv.inner = (void*)(this_obj & (~1));
39178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39180         NetworkGraph_free(this_obj_conv);
39181 }
39182
39183 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
39184         LDKReadOnlyNetworkGraph this_obj_conv;
39185         this_obj_conv.inner = (void*)(this_obj & (~1));
39186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39188         ReadOnlyNetworkGraph_free(this_obj_conv);
39189 }
39190
39191 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
39192         if ((this_ptr & 1) != 0) return;
39193         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39194         CHECK_ACCESS(this_ptr_ptr);
39195         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39196         FREE((void*)this_ptr);
39197         NetworkUpdate_free(this_ptr_conv);
39198 }
39199
39200 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39201         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39202         *ret_copy = NetworkUpdate_clone(arg);
39203 uint32_t ret_ref = (uintptr_t)ret_copy;
39204         return ret_ref;
39205 }
39206 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
39207         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39208         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39209         return ret_conv;
39210 }
39211
39212 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
39213         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39214         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39215         *ret_copy = NetworkUpdate_clone(orig_conv);
39216         uint32_t ret_ref = (uintptr_t)ret_copy;
39217         return ret_ref;
39218 }
39219
39220 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
39221         LDKChannelUpdate msg_conv;
39222         msg_conv.inner = (void*)(msg & (~1));
39223         msg_conv.is_owned = (msg & 1) || (msg == 0);
39224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39225         msg_conv = ChannelUpdate_clone(&msg_conv);
39226         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39227         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39228         uint32_t ret_ref = (uintptr_t)ret_copy;
39229         return ret_ref;
39230 }
39231
39232 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
39233         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39234         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
39235         uint32_t ret_ref = (uintptr_t)ret_copy;
39236         return ret_ref;
39237 }
39238
39239 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
39240         LDKPublicKey node_id_ref;
39241         CHECK(node_id->arr_len == 33);
39242         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
39243         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39244         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39245         uint32_t ret_ref = (uintptr_t)ret_copy;
39246         return ret_ref;
39247 }
39248
39249 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
39250         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39251         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39252         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39253         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39254         CVec_u8Z_free(ret_var);
39255         return ret_arr;
39256 }
39257
39258 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
39259         LDKu8slice ser_ref;
39260         ser_ref.datalen = ser->arr_len;
39261         ser_ref.data = ser->elems;
39262         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39263         *ret_conv = NetworkUpdate_read(ser_ref);
39264         FREE(ser);
39265         return (uint32_t)ret_conv;
39266 }
39267
39268 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
39269         LDKP2PGossipSync this_obj_conv;
39270         this_obj_conv.inner = (void*)(this_obj & (~1));
39271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39273         P2PGossipSync_free(this_obj_conv);
39274 }
39275
39276 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
39277         LDKNetworkGraph network_graph_conv;
39278         network_graph_conv.inner = (void*)(network_graph & (~1));
39279         network_graph_conv.is_owned = false;
39280         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39281         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39282         CHECK_ACCESS(chain_access_ptr);
39283         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39284         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39285         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39286                 // Manually implement clone for Java trait instances
39287                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39288                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39289                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39290                 }
39291         }
39292         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39293         CHECK_ACCESS(logger_ptr);
39294         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39295         if (logger_conv.free == LDKLogger_JCalls_free) {
39296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39297                 LDKLogger_JCalls_cloned(&logger_conv);
39298         }
39299         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
39300         uint32_t ret_ref = 0;
39301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39304         ret_ref = (uintptr_t)ret_var.inner;
39305         if (ret_var.is_owned) {
39306                 ret_ref |= 1;
39307         }
39308         return ret_ref;
39309 }
39310
39311 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
39312         LDKP2PGossipSync this_arg_conv;
39313         this_arg_conv.inner = (void*)(this_arg & (~1));
39314         this_arg_conv.is_owned = false;
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39316         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39317         CHECK_ACCESS(chain_access_ptr);
39318         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39319         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39320         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39321                 // Manually implement clone for Java trait instances
39322                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39323                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39324                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39325                 }
39326         }
39327         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
39328 }
39329
39330 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
39331         LDKNetworkGraph this_arg_conv;
39332         this_arg_conv.inner = (void*)(this_arg & (~1));
39333         this_arg_conv.is_owned = false;
39334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39335         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39336         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
39337         return (uint32_t)ret_ret;
39338 }
39339
39340 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
39341         LDKP2PGossipSync this_arg_conv;
39342         this_arg_conv.inner = (void*)(this_arg & (~1));
39343         this_arg_conv.is_owned = false;
39344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39345         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39346         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
39347         return (uint32_t)ret_ret;
39348 }
39349
39350 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
39351         LDKP2PGossipSync this_arg_conv;
39352         this_arg_conv.inner = (void*)(this_arg & (~1));
39353         this_arg_conv.is_owned = false;
39354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39355         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39356         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
39357         return (uint32_t)ret_ret;
39358 }
39359
39360 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
39361         LDKChannelUpdateInfo this_obj_conv;
39362         this_obj_conv.inner = (void*)(this_obj & (~1));
39363         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39365         ChannelUpdateInfo_free(this_obj_conv);
39366 }
39367
39368 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
39369         LDKChannelUpdateInfo this_ptr_conv;
39370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39371         this_ptr_conv.is_owned = false;
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39373         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39374         return ret_conv;
39375 }
39376
39377 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39378         LDKChannelUpdateInfo this_ptr_conv;
39379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39380         this_ptr_conv.is_owned = false;
39381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39382         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39383 }
39384
39385 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
39386         LDKChannelUpdateInfo this_ptr_conv;
39387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39388         this_ptr_conv.is_owned = false;
39389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39390         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39391         return ret_conv;
39392 }
39393
39394 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
39395         LDKChannelUpdateInfo this_ptr_conv;
39396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39397         this_ptr_conv.is_owned = false;
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39399         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39400 }
39401
39402 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
39403         LDKChannelUpdateInfo this_ptr_conv;
39404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39405         this_ptr_conv.is_owned = false;
39406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39407         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39408         return ret_conv;
39409 }
39410
39411 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
39412         LDKChannelUpdateInfo this_ptr_conv;
39413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39414         this_ptr_conv.is_owned = false;
39415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39416         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39417 }
39418
39419 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
39420         LDKChannelUpdateInfo this_ptr_conv;
39421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39422         this_ptr_conv.is_owned = false;
39423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39424         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39425         return ret_conv;
39426 }
39427
39428 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
39429         LDKChannelUpdateInfo this_ptr_conv;
39430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39431         this_ptr_conv.is_owned = false;
39432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39433         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39434 }
39435
39436 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
39437         LDKChannelUpdateInfo this_ptr_conv;
39438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39439         this_ptr_conv.is_owned = false;
39440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39441         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39442         return ret_conv;
39443 }
39444
39445 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
39446         LDKChannelUpdateInfo this_ptr_conv;
39447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39448         this_ptr_conv.is_owned = false;
39449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39450         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
39451 }
39452
39453 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
39454         LDKChannelUpdateInfo this_ptr_conv;
39455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39456         this_ptr_conv.is_owned = false;
39457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39458         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39459         uint32_t ret_ref = 0;
39460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39463         ret_ref = (uintptr_t)ret_var.inner;
39464         if (ret_var.is_owned) {
39465                 ret_ref |= 1;
39466         }
39467         return ret_ref;
39468 }
39469
39470 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
39471         LDKChannelUpdateInfo this_ptr_conv;
39472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39473         this_ptr_conv.is_owned = false;
39474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39475         LDKRoutingFees val_conv;
39476         val_conv.inner = (void*)(val & (~1));
39477         val_conv.is_owned = (val & 1) || (val == 0);
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39479         val_conv = RoutingFees_clone(&val_conv);
39480         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39481 }
39482
39483 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
39484         LDKChannelUpdateInfo this_ptr_conv;
39485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39486         this_ptr_conv.is_owned = false;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39488         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39489         uint32_t ret_ref = 0;
39490         if ((uintptr_t)ret_var.inner > 4096) {
39491                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39492                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39494                 ret_ref = (uintptr_t)ret_var.inner;
39495                 if (ret_var.is_owned) {
39496                         ret_ref |= 1;
39497                 }
39498         }
39499         return ret_ref;
39500 }
39501
39502 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
39503         LDKChannelUpdateInfo this_ptr_conv;
39504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39505         this_ptr_conv.is_owned = false;
39506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39507         LDKChannelUpdate val_conv;
39508         val_conv.inner = (void*)(val & (~1));
39509         val_conv.is_owned = (val & 1) || (val == 0);
39510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39511         val_conv = ChannelUpdate_clone(&val_conv);
39512         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39513 }
39514
39515 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, int64_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
39516         LDKRoutingFees fees_arg_conv;
39517         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39518         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39519         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39520         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39521         LDKChannelUpdate last_update_message_arg_conv;
39522         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
39523         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39525         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39526         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
39527         uint32_t ret_ref = 0;
39528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39531         ret_ref = (uintptr_t)ret_var.inner;
39532         if (ret_var.is_owned) {
39533                 ret_ref |= 1;
39534         }
39535         return ret_ref;
39536 }
39537
39538 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39539         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39540 uint32_t ret_ref = 0;
39541 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39542 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39543 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39544 ret_ref = (uintptr_t)ret_var.inner;
39545 if (ret_var.is_owned) {
39546         ret_ref |= 1;
39547 }
39548         return ret_ref;
39549 }
39550 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
39551         LDKChannelUpdateInfo arg_conv;
39552         arg_conv.inner = (void*)(arg & (~1));
39553         arg_conv.is_owned = false;
39554         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39555         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
39556         return ret_conv;
39557 }
39558
39559 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
39560         LDKChannelUpdateInfo orig_conv;
39561         orig_conv.inner = (void*)(orig & (~1));
39562         orig_conv.is_owned = false;
39563         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39564         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39565         uint32_t ret_ref = 0;
39566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39569         ret_ref = (uintptr_t)ret_var.inner;
39570         if (ret_var.is_owned) {
39571                 ret_ref |= 1;
39572         }
39573         return ret_ref;
39574 }
39575
39576 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
39577         LDKChannelUpdateInfo obj_conv;
39578         obj_conv.inner = (void*)(obj & (~1));
39579         obj_conv.is_owned = false;
39580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39581         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39584         CVec_u8Z_free(ret_var);
39585         return ret_arr;
39586 }
39587
39588 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
39589         LDKu8slice ser_ref;
39590         ser_ref.datalen = ser->arr_len;
39591         ser_ref.data = ser->elems;
39592         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39593         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39594         FREE(ser);
39595         return (uint32_t)ret_conv;
39596 }
39597
39598 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
39599         LDKChannelInfo this_obj_conv;
39600         this_obj_conv.inner = (void*)(this_obj & (~1));
39601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39603         ChannelInfo_free(this_obj_conv);
39604 }
39605
39606 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
39607         LDKChannelInfo this_ptr_conv;
39608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39609         this_ptr_conv.is_owned = false;
39610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39611         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39612         uint32_t ret_ref = 0;
39613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39616         ret_ref = (uintptr_t)ret_var.inner;
39617         if (ret_var.is_owned) {
39618                 ret_ref |= 1;
39619         }
39620         return ret_ref;
39621 }
39622
39623 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
39624         LDKChannelInfo this_ptr_conv;
39625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39626         this_ptr_conv.is_owned = false;
39627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39628         LDKChannelFeatures val_conv;
39629         val_conv.inner = (void*)(val & (~1));
39630         val_conv.is_owned = (val & 1) || (val == 0);
39631         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39632         val_conv = ChannelFeatures_clone(&val_conv);
39633         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39634 }
39635
39636 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
39637         LDKChannelInfo this_ptr_conv;
39638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39639         this_ptr_conv.is_owned = false;
39640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39641         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39642         uint32_t ret_ref = 0;
39643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39646         ret_ref = (uintptr_t)ret_var.inner;
39647         if (ret_var.is_owned) {
39648                 ret_ref |= 1;
39649         }
39650         return ret_ref;
39651 }
39652
39653 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
39654         LDKChannelInfo this_ptr_conv;
39655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39656         this_ptr_conv.is_owned = false;
39657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39658         LDKNodeId val_conv;
39659         val_conv.inner = (void*)(val & (~1));
39660         val_conv.is_owned = (val & 1) || (val == 0);
39661         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39662         val_conv = NodeId_clone(&val_conv);
39663         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39664 }
39665
39666 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
39667         LDKChannelInfo this_ptr_conv;
39668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39669         this_ptr_conv.is_owned = false;
39670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39671         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39672         uint32_t ret_ref = 0;
39673         if ((uintptr_t)ret_var.inner > 4096) {
39674                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39675                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39677                 ret_ref = (uintptr_t)ret_var.inner;
39678                 if (ret_var.is_owned) {
39679                         ret_ref |= 1;
39680                 }
39681         }
39682         return ret_ref;
39683 }
39684
39685 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
39686         LDKChannelInfo this_ptr_conv;
39687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39688         this_ptr_conv.is_owned = false;
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39690         LDKChannelUpdateInfo val_conv;
39691         val_conv.inner = (void*)(val & (~1));
39692         val_conv.is_owned = (val & 1) || (val == 0);
39693         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39694         val_conv = ChannelUpdateInfo_clone(&val_conv);
39695         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39696 }
39697
39698 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
39699         LDKChannelInfo this_ptr_conv;
39700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39701         this_ptr_conv.is_owned = false;
39702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39703         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39704         uint32_t ret_ref = 0;
39705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39708         ret_ref = (uintptr_t)ret_var.inner;
39709         if (ret_var.is_owned) {
39710                 ret_ref |= 1;
39711         }
39712         return ret_ref;
39713 }
39714
39715 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
39716         LDKChannelInfo this_ptr_conv;
39717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39718         this_ptr_conv.is_owned = false;
39719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39720         LDKNodeId val_conv;
39721         val_conv.inner = (void*)(val & (~1));
39722         val_conv.is_owned = (val & 1) || (val == 0);
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39724         val_conv = NodeId_clone(&val_conv);
39725         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39726 }
39727
39728 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
39729         LDKChannelInfo this_ptr_conv;
39730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39731         this_ptr_conv.is_owned = false;
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39733         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39734         uint32_t ret_ref = 0;
39735         if ((uintptr_t)ret_var.inner > 4096) {
39736                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39737                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39739                 ret_ref = (uintptr_t)ret_var.inner;
39740                 if (ret_var.is_owned) {
39741                         ret_ref |= 1;
39742                 }
39743         }
39744         return ret_ref;
39745 }
39746
39747 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
39748         LDKChannelInfo this_ptr_conv;
39749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39750         this_ptr_conv.is_owned = false;
39751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39752         LDKChannelUpdateInfo val_conv;
39753         val_conv.inner = (void*)(val & (~1));
39754         val_conv.is_owned = (val & 1) || (val == 0);
39755         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39756         val_conv = ChannelUpdateInfo_clone(&val_conv);
39757         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39758 }
39759
39760 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
39761         LDKChannelInfo this_ptr_conv;
39762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39763         this_ptr_conv.is_owned = false;
39764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39765         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39766         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39767         uint32_t ret_ref = (uintptr_t)ret_copy;
39768         return ret_ref;
39769 }
39770
39771 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
39772         LDKChannelInfo this_ptr_conv;
39773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39774         this_ptr_conv.is_owned = false;
39775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39776         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39777         CHECK_ACCESS(val_ptr);
39778         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39779         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39780         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39781 }
39782
39783 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
39784         LDKChannelInfo this_ptr_conv;
39785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39786         this_ptr_conv.is_owned = false;
39787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39788         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39789         uint32_t ret_ref = 0;
39790         if ((uintptr_t)ret_var.inner > 4096) {
39791                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39792                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39794                 ret_ref = (uintptr_t)ret_var.inner;
39795                 if (ret_var.is_owned) {
39796                         ret_ref |= 1;
39797                 }
39798         }
39799         return ret_ref;
39800 }
39801
39802 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39803         LDKChannelInfo this_ptr_conv;
39804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39805         this_ptr_conv.is_owned = false;
39806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39807         LDKChannelAnnouncement val_conv;
39808         val_conv.inner = (void*)(val & (~1));
39809         val_conv.is_owned = (val & 1) || (val == 0);
39810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39811         val_conv = ChannelAnnouncement_clone(&val_conv);
39812         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39813 }
39814
39815 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39816         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39817 uint32_t ret_ref = 0;
39818 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39819 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39820 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39821 ret_ref = (uintptr_t)ret_var.inner;
39822 if (ret_var.is_owned) {
39823         ret_ref |= 1;
39824 }
39825         return ret_ref;
39826 }
39827 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
39828         LDKChannelInfo arg_conv;
39829         arg_conv.inner = (void*)(arg & (~1));
39830         arg_conv.is_owned = false;
39831         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39832         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39833         return ret_conv;
39834 }
39835
39836 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
39837         LDKChannelInfo orig_conv;
39838         orig_conv.inner = (void*)(orig & (~1));
39839         orig_conv.is_owned = false;
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39841         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39842         uint32_t ret_ref = 0;
39843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39846         ret_ref = (uintptr_t)ret_var.inner;
39847         if (ret_var.is_owned) {
39848                 ret_ref |= 1;
39849         }
39850         return ret_ref;
39851 }
39852
39853 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
39854         LDKChannelInfo this_arg_conv;
39855         this_arg_conv.inner = (void*)(this_arg & (~1));
39856         this_arg_conv.is_owned = false;
39857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39858         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39859         uint32_t ret_ref = 0;
39860         if ((uintptr_t)ret_var.inner > 4096) {
39861                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39862                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39864                 ret_ref = (uintptr_t)ret_var.inner;
39865                 if (ret_var.is_owned) {
39866                         ret_ref |= 1;
39867                 }
39868         }
39869         return ret_ref;
39870 }
39871
39872 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
39873         LDKChannelInfo obj_conv;
39874         obj_conv.inner = (void*)(obj & (~1));
39875         obj_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39877         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39878         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39879         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39880         CVec_u8Z_free(ret_var);
39881         return ret_arr;
39882 }
39883
39884 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
39885         LDKu8slice ser_ref;
39886         ser_ref.datalen = ser->arr_len;
39887         ser_ref.data = ser->elems;
39888         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39889         *ret_conv = ChannelInfo_read(ser_ref);
39890         FREE(ser);
39891         return (uint32_t)ret_conv;
39892 }
39893
39894 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
39895         LDKDirectedChannelInfo this_obj_conv;
39896         this_obj_conv.inner = (void*)(this_obj & (~1));
39897         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39899         DirectedChannelInfo_free(this_obj_conv);
39900 }
39901
39902 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39903         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39904 uint32_t ret_ref = 0;
39905 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39906 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39907 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39908 ret_ref = (uintptr_t)ret_var.inner;
39909 if (ret_var.is_owned) {
39910         ret_ref |= 1;
39911 }
39912         return ret_ref;
39913 }
39914 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
39915         LDKDirectedChannelInfo arg_conv;
39916         arg_conv.inner = (void*)(arg & (~1));
39917         arg_conv.is_owned = false;
39918         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39919         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
39920         return ret_conv;
39921 }
39922
39923 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
39924         LDKDirectedChannelInfo orig_conv;
39925         orig_conv.inner = (void*)(orig & (~1));
39926         orig_conv.is_owned = false;
39927         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39928         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39929         uint32_t ret_ref = 0;
39930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39933         ret_ref = (uintptr_t)ret_var.inner;
39934         if (ret_var.is_owned) {
39935                 ret_ref |= 1;
39936         }
39937         return ret_ref;
39938 }
39939
39940 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
39941         LDKDirectedChannelInfo this_arg_conv;
39942         this_arg_conv.inner = (void*)(this_arg & (~1));
39943         this_arg_conv.is_owned = false;
39944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39945         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39946         uint32_t ret_ref = 0;
39947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39950         ret_ref = (uintptr_t)ret_var.inner;
39951         if (ret_var.is_owned) {
39952                 ret_ref |= 1;
39953         }
39954         return ret_ref;
39955 }
39956
39957 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
39958         LDKDirectedChannelInfo this_arg_conv;
39959         this_arg_conv.inner = (void*)(this_arg & (~1));
39960         this_arg_conv.is_owned = false;
39961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39962         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
39963         uint32_t ret_ref = 0;
39964         if ((uintptr_t)ret_var.inner > 4096) {
39965                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39966                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39968                 ret_ref = (uintptr_t)ret_var.inner;
39969                 if (ret_var.is_owned) {
39970                         ret_ref |= 1;
39971                 }
39972         }
39973         return ret_ref;
39974 }
39975
39976 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
39977         LDKDirectedChannelInfo this_arg_conv;
39978         this_arg_conv.inner = (void*)(this_arg & (~1));
39979         this_arg_conv.is_owned = false;
39980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39981         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
39982         return ret_conv;
39983 }
39984
39985 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
39986         LDKDirectedChannelInfo this_arg_conv;
39987         this_arg_conv.inner = (void*)(this_arg & (~1));
39988         this_arg_conv.is_owned = false;
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39990         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39991         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
39992         uint32_t ret_ref = (uintptr_t)ret_copy;
39993         return ret_ref;
39994 }
39995
39996 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
39997         if ((this_ptr & 1) != 0) return;
39998         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39999         CHECK_ACCESS(this_ptr_ptr);
40000         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40001         FREE((void*)this_ptr);
40002         EffectiveCapacity_free(this_ptr_conv);
40003 }
40004
40005 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40006         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40007         *ret_copy = EffectiveCapacity_clone(arg);
40008 uint32_t ret_ref = (uintptr_t)ret_copy;
40009         return ret_ref;
40010 }
40011 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
40012         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40013         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40014         return ret_conv;
40015 }
40016
40017 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
40018         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40019         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40020         *ret_copy = EffectiveCapacity_clone(orig_conv);
40021         uint32_t ret_ref = (uintptr_t)ret_copy;
40022         return ret_ref;
40023 }
40024
40025 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
40026         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40027         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40028         uint32_t ret_ref = (uintptr_t)ret_copy;
40029         return ret_ref;
40030 }
40031
40032 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
40033         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40034         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40035         uint32_t ret_ref = (uintptr_t)ret_copy;
40036         return ret_ref;
40037 }
40038
40039 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint32_t htlc_maximum_msat) {
40040         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
40041         CHECK_ACCESS(htlc_maximum_msat_ptr);
40042         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
40043         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
40044         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40045         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
40046         uint32_t ret_ref = (uintptr_t)ret_copy;
40047         return ret_ref;
40048 }
40049
40050 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
40051         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40052         *ret_copy = EffectiveCapacity_infinite();
40053         uint32_t ret_ref = (uintptr_t)ret_copy;
40054         return ret_ref;
40055 }
40056
40057 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
40058         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40059         *ret_copy = EffectiveCapacity_unknown();
40060         uint32_t ret_ref = (uintptr_t)ret_copy;
40061         return ret_ref;
40062 }
40063
40064 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
40065         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40066         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40067         return ret_conv;
40068 }
40069
40070 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
40071         LDKRoutingFees this_obj_conv;
40072         this_obj_conv.inner = (void*)(this_obj & (~1));
40073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40075         RoutingFees_free(this_obj_conv);
40076 }
40077
40078 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
40079         LDKRoutingFees this_ptr_conv;
40080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40081         this_ptr_conv.is_owned = false;
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40083         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40084         return ret_conv;
40085 }
40086
40087 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
40088         LDKRoutingFees this_ptr_conv;
40089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40090         this_ptr_conv.is_owned = false;
40091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40092         RoutingFees_set_base_msat(&this_ptr_conv, val);
40093 }
40094
40095 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
40096         LDKRoutingFees this_ptr_conv;
40097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40098         this_ptr_conv.is_owned = false;
40099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40100         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40101         return ret_conv;
40102 }
40103
40104 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
40105         LDKRoutingFees this_ptr_conv;
40106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40107         this_ptr_conv.is_owned = false;
40108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40109         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40110 }
40111
40112 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
40113         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40114         uint32_t ret_ref = 0;
40115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40118         ret_ref = (uintptr_t)ret_var.inner;
40119         if (ret_var.is_owned) {
40120                 ret_ref |= 1;
40121         }
40122         return ret_ref;
40123 }
40124
40125 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
40126         LDKRoutingFees a_conv;
40127         a_conv.inner = (void*)(a & (~1));
40128         a_conv.is_owned = false;
40129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40130         LDKRoutingFees b_conv;
40131         b_conv.inner = (void*)(b & (~1));
40132         b_conv.is_owned = false;
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40134         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40135         return ret_conv;
40136 }
40137
40138 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40139         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40140 uint32_t ret_ref = 0;
40141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40144 ret_ref = (uintptr_t)ret_var.inner;
40145 if (ret_var.is_owned) {
40146         ret_ref |= 1;
40147 }
40148         return ret_ref;
40149 }
40150 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
40151         LDKRoutingFees arg_conv;
40152         arg_conv.inner = (void*)(arg & (~1));
40153         arg_conv.is_owned = false;
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40155         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40156         return ret_conv;
40157 }
40158
40159 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
40160         LDKRoutingFees orig_conv;
40161         orig_conv.inner = (void*)(orig & (~1));
40162         orig_conv.is_owned = false;
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40164         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40165         uint32_t ret_ref = 0;
40166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40169         ret_ref = (uintptr_t)ret_var.inner;
40170         if (ret_var.is_owned) {
40171                 ret_ref |= 1;
40172         }
40173         return ret_ref;
40174 }
40175
40176 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
40177         LDKRoutingFees o_conv;
40178         o_conv.inner = (void*)(o & (~1));
40179         o_conv.is_owned = false;
40180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40181         int64_t ret_conv = RoutingFees_hash(&o_conv);
40182         return ret_conv;
40183 }
40184
40185 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
40186         LDKRoutingFees obj_conv;
40187         obj_conv.inner = (void*)(obj & (~1));
40188         obj_conv.is_owned = false;
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40190         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40191         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40192         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40193         CVec_u8Z_free(ret_var);
40194         return ret_arr;
40195 }
40196
40197 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
40198         LDKu8slice ser_ref;
40199         ser_ref.datalen = ser->arr_len;
40200         ser_ref.data = ser->elems;
40201         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40202         *ret_conv = RoutingFees_read(ser_ref);
40203         FREE(ser);
40204         return (uint32_t)ret_conv;
40205 }
40206
40207 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
40208         LDKNodeAnnouncementInfo this_obj_conv;
40209         this_obj_conv.inner = (void*)(this_obj & (~1));
40210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40212         NodeAnnouncementInfo_free(this_obj_conv);
40213 }
40214
40215 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
40216         LDKNodeAnnouncementInfo this_ptr_conv;
40217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40218         this_ptr_conv.is_owned = false;
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40220         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40221         uint32_t ret_ref = 0;
40222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40225         ret_ref = (uintptr_t)ret_var.inner;
40226         if (ret_var.is_owned) {
40227                 ret_ref |= 1;
40228         }
40229         return ret_ref;
40230 }
40231
40232 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
40233         LDKNodeAnnouncementInfo this_ptr_conv;
40234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40235         this_ptr_conv.is_owned = false;
40236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40237         LDKNodeFeatures val_conv;
40238         val_conv.inner = (void*)(val & (~1));
40239         val_conv.is_owned = (val & 1) || (val == 0);
40240         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40241         val_conv = NodeFeatures_clone(&val_conv);
40242         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40243 }
40244
40245 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
40246         LDKNodeAnnouncementInfo this_ptr_conv;
40247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40248         this_ptr_conv.is_owned = false;
40249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40250         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40251         return ret_conv;
40252 }
40253
40254 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
40255         LDKNodeAnnouncementInfo this_ptr_conv;
40256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40257         this_ptr_conv.is_owned = false;
40258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40259         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40260 }
40261
40262 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
40263         LDKNodeAnnouncementInfo this_ptr_conv;
40264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40265         this_ptr_conv.is_owned = false;
40266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40267         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
40268         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
40269         return ret_arr;
40270 }
40271
40272 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
40273         LDKNodeAnnouncementInfo this_ptr_conv;
40274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40275         this_ptr_conv.is_owned = false;
40276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40277         LDKThreeBytes val_ref;
40278         CHECK(val->arr_len == 3);
40279         memcpy(val_ref.data, val->elems, 3); FREE(val);
40280         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40281 }
40282
40283 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
40284         LDKNodeAnnouncementInfo this_ptr_conv;
40285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40286         this_ptr_conv.is_owned = false;
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40288         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
40289         uint32_t ret_ref = 0;
40290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40293         ret_ref = (uintptr_t)ret_var.inner;
40294         if (ret_var.is_owned) {
40295                 ret_ref |= 1;
40296         }
40297         return ret_ref;
40298 }
40299
40300 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, uint32_t val) {
40301         LDKNodeAnnouncementInfo this_ptr_conv;
40302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40303         this_ptr_conv.is_owned = false;
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40305         LDKNodeAlias val_conv;
40306         val_conv.inner = (void*)(val & (~1));
40307         val_conv.is_owned = (val & 1) || (val == 0);
40308         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40309         val_conv = NodeAlias_clone(&val_conv);
40310         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
40311 }
40312
40313 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
40314         LDKNodeAnnouncementInfo this_ptr_conv;
40315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40316         this_ptr_conv.is_owned = false;
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40318         LDKCVec_NetAddressZ val_constr;
40319         val_constr.datalen = val->arr_len;
40320         if (val_constr.datalen > 0)
40321                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40322         else
40323                 val_constr.data = NULL;
40324         uint32_t* val_vals = val->elems;
40325         for (size_t m = 0; m < val_constr.datalen; m++) {
40326                 uint32_t val_conv_12 = val_vals[m];
40327                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40328                 CHECK_ACCESS(val_conv_12_ptr);
40329                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40330                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40331                 val_constr.data[m] = val_conv_12_conv;
40332         }
40333         FREE(val);
40334         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40335 }
40336
40337 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
40338         LDKNodeAnnouncementInfo this_ptr_conv;
40339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40340         this_ptr_conv.is_owned = false;
40341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40342         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40343         uint32_t ret_ref = 0;
40344         if ((uintptr_t)ret_var.inner > 4096) {
40345                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40346                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40348                 ret_ref = (uintptr_t)ret_var.inner;
40349                 if (ret_var.is_owned) {
40350                         ret_ref |= 1;
40351                 }
40352         }
40353         return ret_ref;
40354 }
40355
40356 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
40357         LDKNodeAnnouncementInfo this_ptr_conv;
40358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40359         this_ptr_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40361         LDKNodeAnnouncement val_conv;
40362         val_conv.inner = (void*)(val & (~1));
40363         val_conv.is_owned = (val & 1) || (val == 0);
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40365         val_conv = NodeAnnouncement_clone(&val_conv);
40366         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40367 }
40368
40369 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_new"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, uint32_t alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
40370         LDKNodeFeatures features_arg_conv;
40371         features_arg_conv.inner = (void*)(features_arg & (~1));
40372         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40373         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40374         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40375         LDKThreeBytes rgb_arg_ref;
40376         CHECK(rgb_arg->arr_len == 3);
40377         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
40378         LDKNodeAlias alias_arg_conv;
40379         alias_arg_conv.inner = (void*)(alias_arg & (~1));
40380         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
40381         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
40382         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
40383         LDKCVec_NetAddressZ addresses_arg_constr;
40384         addresses_arg_constr.datalen = addresses_arg->arr_len;
40385         if (addresses_arg_constr.datalen > 0)
40386                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40387         else
40388                 addresses_arg_constr.data = NULL;
40389         uint32_t* addresses_arg_vals = addresses_arg->elems;
40390         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40391                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
40392                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40393                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40394                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40395                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40396         }
40397         FREE(addresses_arg);
40398         LDKNodeAnnouncement announcement_message_arg_conv;
40399         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40400         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40401         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40402         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40403         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
40404         uint32_t ret_ref = 0;
40405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40408         ret_ref = (uintptr_t)ret_var.inner;
40409         if (ret_var.is_owned) {
40410                 ret_ref |= 1;
40411         }
40412         return ret_ref;
40413 }
40414
40415 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40416         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40417 uint32_t ret_ref = 0;
40418 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40419 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40421 ret_ref = (uintptr_t)ret_var.inner;
40422 if (ret_var.is_owned) {
40423         ret_ref |= 1;
40424 }
40425         return ret_ref;
40426 }
40427 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
40428         LDKNodeAnnouncementInfo arg_conv;
40429         arg_conv.inner = (void*)(arg & (~1));
40430         arg_conv.is_owned = false;
40431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40432         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40433         return ret_conv;
40434 }
40435
40436 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
40437         LDKNodeAnnouncementInfo orig_conv;
40438         orig_conv.inner = (void*)(orig & (~1));
40439         orig_conv.is_owned = false;
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40441         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40442         uint32_t ret_ref = 0;
40443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40446         ret_ref = (uintptr_t)ret_var.inner;
40447         if (ret_var.is_owned) {
40448                 ret_ref |= 1;
40449         }
40450         return ret_ref;
40451 }
40452
40453 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
40454         LDKNodeAnnouncementInfo obj_conv;
40455         obj_conv.inner = (void*)(obj & (~1));
40456         obj_conv.is_owned = false;
40457         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40458         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40459         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40460         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40461         CVec_u8Z_free(ret_var);
40462         return ret_arr;
40463 }
40464
40465 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
40466         LDKu8slice ser_ref;
40467         ser_ref.datalen = ser->arr_len;
40468         ser_ref.data = ser->elems;
40469         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40470         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40471         FREE(ser);
40472         return (uint32_t)ret_conv;
40473 }
40474
40475 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint32_t this_obj) {
40476         LDKNodeAlias this_obj_conv;
40477         this_obj_conv.inner = (void*)(this_obj & (~1));
40478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40480         NodeAlias_free(this_obj_conv);
40481 }
40482
40483 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint32_t this_ptr) {
40484         LDKNodeAlias this_ptr_conv;
40485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40486         this_ptr_conv.is_owned = false;
40487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40488         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40489         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
40490         return ret_arr;
40491 }
40492
40493 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint32_t this_ptr, int8_tArray val) {
40494         LDKNodeAlias this_ptr_conv;
40495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40496         this_ptr_conv.is_owned = false;
40497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40498         LDKThirtyTwoBytes val_ref;
40499         CHECK(val->arr_len == 32);
40500         memcpy(val_ref.data, val->elems, 32); FREE(val);
40501         NodeAlias_set_a(&this_ptr_conv, val_ref);
40502 }
40503
40504 uint32_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
40505         LDKThirtyTwoBytes a_arg_ref;
40506         CHECK(a_arg->arr_len == 32);
40507         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
40508         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
40509         uint32_t ret_ref = 0;
40510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40513         ret_ref = (uintptr_t)ret_var.inner;
40514         if (ret_var.is_owned) {
40515                 ret_ref |= 1;
40516         }
40517         return ret_ref;
40518 }
40519
40520 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
40521         LDKNodeAlias ret_var = NodeAlias_clone(arg);
40522 uint32_t ret_ref = 0;
40523 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40524 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40525 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40526 ret_ref = (uintptr_t)ret_var.inner;
40527 if (ret_var.is_owned) {
40528         ret_ref |= 1;
40529 }
40530         return ret_ref;
40531 }
40532 uint32_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint32_t arg) {
40533         LDKNodeAlias arg_conv;
40534         arg_conv.inner = (void*)(arg & (~1));
40535         arg_conv.is_owned = false;
40536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40537         uint32_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
40538         return ret_conv;
40539 }
40540
40541 uint32_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint32_t orig) {
40542         LDKNodeAlias orig_conv;
40543         orig_conv.inner = (void*)(orig & (~1));
40544         orig_conv.is_owned = false;
40545         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40546         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
40547         uint32_t ret_ref = 0;
40548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40551         ret_ref = (uintptr_t)ret_var.inner;
40552         if (ret_var.is_owned) {
40553                 ret_ref |= 1;
40554         }
40555         return ret_ref;
40556 }
40557
40558 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint32_t obj) {
40559         LDKNodeAlias obj_conv;
40560         obj_conv.inner = (void*)(obj & (~1));
40561         obj_conv.is_owned = false;
40562         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40563         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
40564         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40565         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40566         CVec_u8Z_free(ret_var);
40567         return ret_arr;
40568 }
40569
40570 uint32_t  __attribute__((export_name("TS_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
40571         LDKu8slice ser_ref;
40572         ser_ref.datalen = ser->arr_len;
40573         ser_ref.data = ser->elems;
40574         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
40575         *ret_conv = NodeAlias_read(ser_ref);
40576         FREE(ser);
40577         return (uint32_t)ret_conv;
40578 }
40579
40580 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
40581         LDKNodeInfo this_obj_conv;
40582         this_obj_conv.inner = (void*)(this_obj & (~1));
40583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40585         NodeInfo_free(this_obj_conv);
40586 }
40587
40588 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
40589         LDKNodeInfo this_ptr_conv;
40590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40591         this_ptr_conv.is_owned = false;
40592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40593         LDKCVec_u64Z val_constr;
40594         val_constr.datalen = val->arr_len;
40595         if (val_constr.datalen > 0)
40596                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40597         else
40598                 val_constr.data = NULL;
40599         int64_t* val_vals = val->elems;
40600         for (size_t i = 0; i < val_constr.datalen; i++) {
40601                 int64_t val_conv_8 = val_vals[i];
40602                 val_constr.data[i] = val_conv_8;
40603         }
40604         FREE(val);
40605         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40606 }
40607
40608 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
40609         LDKNodeInfo this_ptr_conv;
40610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40611         this_ptr_conv.is_owned = false;
40612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40613         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40614         uint32_t ret_ref = 0;
40615         if ((uintptr_t)ret_var.inner > 4096) {
40616                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40617                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40619                 ret_ref = (uintptr_t)ret_var.inner;
40620                 if (ret_var.is_owned) {
40621                         ret_ref |= 1;
40622                 }
40623         }
40624         return ret_ref;
40625 }
40626
40627 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) {
40628         LDKNodeInfo this_ptr_conv;
40629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40630         this_ptr_conv.is_owned = false;
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40632         LDKRoutingFees val_conv;
40633         val_conv.inner = (void*)(val & (~1));
40634         val_conv.is_owned = (val & 1) || (val == 0);
40635         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40636         val_conv = RoutingFees_clone(&val_conv);
40637         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40638 }
40639
40640 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
40641         LDKNodeInfo this_ptr_conv;
40642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40643         this_ptr_conv.is_owned = false;
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40645         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40646         uint32_t ret_ref = 0;
40647         if ((uintptr_t)ret_var.inner > 4096) {
40648                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40649                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40651                 ret_ref = (uintptr_t)ret_var.inner;
40652                 if (ret_var.is_owned) {
40653                         ret_ref |= 1;
40654                 }
40655         }
40656         return ret_ref;
40657 }
40658
40659 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
40660         LDKNodeInfo this_ptr_conv;
40661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40662         this_ptr_conv.is_owned = false;
40663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40664         LDKNodeAnnouncementInfo val_conv;
40665         val_conv.inner = (void*)(val & (~1));
40666         val_conv.is_owned = (val & 1) || (val == 0);
40667         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40668         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40669         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40670 }
40671
40672 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) {
40673         LDKCVec_u64Z channels_arg_constr;
40674         channels_arg_constr.datalen = channels_arg->arr_len;
40675         if (channels_arg_constr.datalen > 0)
40676                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40677         else
40678                 channels_arg_constr.data = NULL;
40679         int64_t* channels_arg_vals = channels_arg->elems;
40680         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
40681                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
40682                 channels_arg_constr.data[i] = channels_arg_conv_8;
40683         }
40684         FREE(channels_arg);
40685         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40686         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40687         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40689         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40690         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40691         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40692         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40693         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40694         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40695         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40696         uint32_t ret_ref = 0;
40697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40700         ret_ref = (uintptr_t)ret_var.inner;
40701         if (ret_var.is_owned) {
40702                 ret_ref |= 1;
40703         }
40704         return ret_ref;
40705 }
40706
40707 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40708         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40709 uint32_t ret_ref = 0;
40710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40713 ret_ref = (uintptr_t)ret_var.inner;
40714 if (ret_var.is_owned) {
40715         ret_ref |= 1;
40716 }
40717         return ret_ref;
40718 }
40719 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
40720         LDKNodeInfo arg_conv;
40721         arg_conv.inner = (void*)(arg & (~1));
40722         arg_conv.is_owned = false;
40723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40724         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40725         return ret_conv;
40726 }
40727
40728 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
40729         LDKNodeInfo orig_conv;
40730         orig_conv.inner = (void*)(orig & (~1));
40731         orig_conv.is_owned = false;
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40733         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40734         uint32_t ret_ref = 0;
40735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40738         ret_ref = (uintptr_t)ret_var.inner;
40739         if (ret_var.is_owned) {
40740                 ret_ref |= 1;
40741         }
40742         return ret_ref;
40743 }
40744
40745 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
40746         LDKNodeInfo obj_conv;
40747         obj_conv.inner = (void*)(obj & (~1));
40748         obj_conv.is_owned = false;
40749         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40750         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40751         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40752         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40753         CVec_u8Z_free(ret_var);
40754         return ret_arr;
40755 }
40756
40757 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40758         LDKu8slice ser_ref;
40759         ser_ref.datalen = ser->arr_len;
40760         ser_ref.data = ser->elems;
40761         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40762         *ret_conv = NodeInfo_read(ser_ref);
40763         FREE(ser);
40764         return (uint32_t)ret_conv;
40765 }
40766
40767 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
40768         LDKNetworkGraph obj_conv;
40769         obj_conv.inner = (void*)(obj & (~1));
40770         obj_conv.is_owned = false;
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40772         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40773         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40774         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40775         CVec_u8Z_free(ret_var);
40776         return ret_arr;
40777 }
40778
40779 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
40780         LDKu8slice ser_ref;
40781         ser_ref.datalen = ser->arr_len;
40782         ser_ref.data = ser->elems;
40783         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
40784         CHECK_ACCESS(arg_ptr);
40785         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40786         if (arg_conv.free == LDKLogger_JCalls_free) {
40787                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40788                 LDKLogger_JCalls_cloned(&arg_conv);
40789         }
40790         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40791         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40792         FREE(ser);
40793         return (uint32_t)ret_conv;
40794 }
40795
40796 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
40797         LDKThirtyTwoBytes genesis_hash_ref;
40798         CHECK(genesis_hash->arr_len == 32);
40799         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40800         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40801         CHECK_ACCESS(logger_ptr);
40802         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40803         if (logger_conv.free == LDKLogger_JCalls_free) {
40804                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40805                 LDKLogger_JCalls_cloned(&logger_conv);
40806         }
40807         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40808         uint32_t ret_ref = 0;
40809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40812         ret_ref = (uintptr_t)ret_var.inner;
40813         if (ret_var.is_owned) {
40814                 ret_ref |= 1;
40815         }
40816         return ret_ref;
40817 }
40818
40819 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
40820         LDKNetworkGraph this_arg_conv;
40821         this_arg_conv.inner = (void*)(this_arg & (~1));
40822         this_arg_conv.is_owned = false;
40823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40824         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40825         uint32_t ret_ref = 0;
40826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40829         ret_ref = (uintptr_t)ret_var.inner;
40830         if (ret_var.is_owned) {
40831                 ret_ref |= 1;
40832         }
40833         return ret_ref;
40834 }
40835
40836 uint32_t  __attribute__((export_name("TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp(uint32_t this_arg) {
40837         LDKNetworkGraph this_arg_conv;
40838         this_arg_conv.inner = (void*)(this_arg & (~1));
40839         this_arg_conv.is_owned = false;
40840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40841         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
40842         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
40843         uint32_t ret_ref = (uintptr_t)ret_copy;
40844         return ret_ref;
40845 }
40846
40847 void  __attribute__((export_name("TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp(uint32_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
40848         LDKNetworkGraph this_arg_conv;
40849         this_arg_conv.inner = (void*)(this_arg & (~1));
40850         this_arg_conv.is_owned = false;
40851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40852         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
40853 }
40854
40855 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
40856         LDKNetworkGraph this_arg_conv;
40857         this_arg_conv.inner = (void*)(this_arg & (~1));
40858         this_arg_conv.is_owned = false;
40859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40860         LDKNodeAnnouncement msg_conv;
40861         msg_conv.inner = (void*)(msg & (~1));
40862         msg_conv.is_owned = false;
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40864         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40865         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40866         return (uint32_t)ret_conv;
40867 }
40868
40869 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) {
40870         LDKNetworkGraph this_arg_conv;
40871         this_arg_conv.inner = (void*)(this_arg & (~1));
40872         this_arg_conv.is_owned = false;
40873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40874         LDKUnsignedNodeAnnouncement msg_conv;
40875         msg_conv.inner = (void*)(msg & (~1));
40876         msg_conv.is_owned = false;
40877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40878         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40879         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40880         return (uint32_t)ret_conv;
40881 }
40882
40883 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) {
40884         LDKNetworkGraph this_arg_conv;
40885         this_arg_conv.inner = (void*)(this_arg & (~1));
40886         this_arg_conv.is_owned = false;
40887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40888         LDKChannelAnnouncement msg_conv;
40889         msg_conv.inner = (void*)(msg & (~1));
40890         msg_conv.is_owned = false;
40891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40892         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40893         CHECK_ACCESS(chain_access_ptr);
40894         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40895         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40896         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40897                 // Manually implement clone for Java trait instances
40898                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40899                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40900                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40901                 }
40902         }
40903         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40904         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40905         return (uint32_t)ret_conv;
40906 }
40907
40908 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) {
40909         LDKNetworkGraph this_arg_conv;
40910         this_arg_conv.inner = (void*)(this_arg & (~1));
40911         this_arg_conv.is_owned = false;
40912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40913         LDKUnsignedChannelAnnouncement msg_conv;
40914         msg_conv.inner = (void*)(msg & (~1));
40915         msg_conv.is_owned = false;
40916         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40917         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40918         CHECK_ACCESS(chain_access_ptr);
40919         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40920         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40921         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40922                 // Manually implement clone for Java trait instances
40923                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40924                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40925                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40926                 }
40927         }
40928         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40929         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40930         return (uint32_t)ret_conv;
40931 }
40932
40933 uint32_t  __attribute__((export_name("TS_NetworkGraph_add_channel_from_partial_announcement"))) TS_NetworkGraph_add_channel_from_partial_announcement(uint32_t this_arg, int64_t short_channel_id, int64_t timestamp, uint32_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
40934         LDKNetworkGraph this_arg_conv;
40935         this_arg_conv.inner = (void*)(this_arg & (~1));
40936         this_arg_conv.is_owned = false;
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40938         LDKChannelFeatures features_conv;
40939         features_conv.inner = (void*)(features & (~1));
40940         features_conv.is_owned = (features & 1) || (features == 0);
40941         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
40942         features_conv = ChannelFeatures_clone(&features_conv);
40943         LDKPublicKey node_id_1_ref;
40944         CHECK(node_id_1->arr_len == 33);
40945         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
40946         LDKPublicKey node_id_2_ref;
40947         CHECK(node_id_2->arr_len == 33);
40948         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
40949         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40950         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
40951         return (uint32_t)ret_conv;
40952 }
40953
40954 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40955         LDKNetworkGraph this_arg_conv;
40956         this_arg_conv.inner = (void*)(this_arg & (~1));
40957         this_arg_conv.is_owned = false;
40958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40959         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
40960 }
40961
40962 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40963         LDKNetworkGraph this_arg_conv;
40964         this_arg_conv.inner = (void*)(this_arg & (~1));
40965         this_arg_conv.is_owned = false;
40966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40967         LDKPublicKey _node_id_ref;
40968         CHECK(_node_id->arr_len == 33);
40969         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
40970         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
40971 }
40972
40973 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) {
40974         LDKNetworkGraph this_arg_conv;
40975         this_arg_conv.inner = (void*)(this_arg & (~1));
40976         this_arg_conv.is_owned = false;
40977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40978         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
40979 }
40980
40981 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
40982         LDKNetworkGraph this_arg_conv;
40983         this_arg_conv.inner = (void*)(this_arg & (~1));
40984         this_arg_conv.is_owned = false;
40985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40986         LDKChannelUpdate msg_conv;
40987         msg_conv.inner = (void*)(msg & (~1));
40988         msg_conv.is_owned = false;
40989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40990         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40991         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
40992         return (uint32_t)ret_conv;
40993 }
40994
40995 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
40996         LDKNetworkGraph this_arg_conv;
40997         this_arg_conv.inner = (void*)(this_arg & (~1));
40998         this_arg_conv.is_owned = false;
40999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41000         LDKUnsignedChannelUpdate msg_conv;
41001         msg_conv.inner = (void*)(msg & (~1));
41002         msg_conv.is_owned = false;
41003         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41004         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41005         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41006         return (uint32_t)ret_conv;
41007 }
41008
41009 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_channel"))) TS_ReadOnlyNetworkGraph_channel(uint32_t this_arg, int64_t short_channel_id) {
41010         LDKReadOnlyNetworkGraph this_arg_conv;
41011         this_arg_conv.inner = (void*)(this_arg & (~1));
41012         this_arg_conv.is_owned = false;
41013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41014         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
41015         uint32_t ret_ref = 0;
41016         if ((uintptr_t)ret_var.inner > 4096) {
41017                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41018                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41020                 ret_ref = (uintptr_t)ret_var.inner;
41021                 if (ret_var.is_owned) {
41022                         ret_ref |= 1;
41023                 }
41024         }
41025         return ret_ref;
41026 }
41027
41028 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_node"))) TS_ReadOnlyNetworkGraph_node(uint32_t this_arg, uint32_t node_id) {
41029         LDKReadOnlyNetworkGraph this_arg_conv;
41030         this_arg_conv.inner = (void*)(this_arg & (~1));
41031         this_arg_conv.is_owned = false;
41032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41033         LDKNodeId node_id_conv;
41034         node_id_conv.inner = (void*)(node_id & (~1));
41035         node_id_conv.is_owned = false;
41036         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
41037         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
41038         uint32_t ret_ref = 0;
41039         if ((uintptr_t)ret_var.inner > 4096) {
41040                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41041                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41043                 ret_ref = (uintptr_t)ret_var.inner;
41044                 if (ret_var.is_owned) {
41045                         ret_ref |= 1;
41046                 }
41047         }
41048         return ret_ref;
41049 }
41050
41051 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
41052         LDKReadOnlyNetworkGraph this_arg_conv;
41053         this_arg_conv.inner = (void*)(this_arg & (~1));
41054         this_arg_conv.is_owned = false;
41055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41056         LDKPublicKey pubkey_ref;
41057         CHECK(pubkey->arr_len == 33);
41058         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41059         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41060         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41061         uint32_t ret_ref = (uintptr_t)ret_copy;
41062         return ret_ref;
41063 }
41064
41065 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
41066         LDKRouteHop this_obj_conv;
41067         this_obj_conv.inner = (void*)(this_obj & (~1));
41068         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41070         RouteHop_free(this_obj_conv);
41071 }
41072
41073 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
41074         LDKRouteHop this_ptr_conv;
41075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41076         this_ptr_conv.is_owned = false;
41077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41078         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41079         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
41080         return ret_arr;
41081 }
41082
41083 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
41084         LDKRouteHop this_ptr_conv;
41085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41086         this_ptr_conv.is_owned = false;
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41088         LDKPublicKey val_ref;
41089         CHECK(val->arr_len == 33);
41090         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41091         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41092 }
41093
41094 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
41095         LDKRouteHop this_ptr_conv;
41096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41097         this_ptr_conv.is_owned = false;
41098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41099         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41100         uint32_t ret_ref = 0;
41101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41104         ret_ref = (uintptr_t)ret_var.inner;
41105         if (ret_var.is_owned) {
41106                 ret_ref |= 1;
41107         }
41108         return ret_ref;
41109 }
41110
41111 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
41112         LDKRouteHop this_ptr_conv;
41113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41114         this_ptr_conv.is_owned = false;
41115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41116         LDKNodeFeatures val_conv;
41117         val_conv.inner = (void*)(val & (~1));
41118         val_conv.is_owned = (val & 1) || (val == 0);
41119         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41120         val_conv = NodeFeatures_clone(&val_conv);
41121         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41122 }
41123
41124 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
41125         LDKRouteHop this_ptr_conv;
41126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41127         this_ptr_conv.is_owned = false;
41128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41129         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41130         return ret_conv;
41131 }
41132
41133 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
41134         LDKRouteHop this_ptr_conv;
41135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41136         this_ptr_conv.is_owned = false;
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41138         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41139 }
41140
41141 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
41142         LDKRouteHop this_ptr_conv;
41143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41144         this_ptr_conv.is_owned = false;
41145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41146         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41147         uint32_t ret_ref = 0;
41148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41151         ret_ref = (uintptr_t)ret_var.inner;
41152         if (ret_var.is_owned) {
41153                 ret_ref |= 1;
41154         }
41155         return ret_ref;
41156 }
41157
41158 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
41159         LDKRouteHop this_ptr_conv;
41160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41161         this_ptr_conv.is_owned = false;
41162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41163         LDKChannelFeatures val_conv;
41164         val_conv.inner = (void*)(val & (~1));
41165         val_conv.is_owned = (val & 1) || (val == 0);
41166         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41167         val_conv = ChannelFeatures_clone(&val_conv);
41168         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41169 }
41170
41171 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
41172         LDKRouteHop this_ptr_conv;
41173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41174         this_ptr_conv.is_owned = false;
41175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41176         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41177         return ret_conv;
41178 }
41179
41180 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
41181         LDKRouteHop this_ptr_conv;
41182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41183         this_ptr_conv.is_owned = false;
41184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41185         RouteHop_set_fee_msat(&this_ptr_conv, val);
41186 }
41187
41188 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
41189         LDKRouteHop this_ptr_conv;
41190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41191         this_ptr_conv.is_owned = false;
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41193         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41194         return ret_conv;
41195 }
41196
41197 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
41198         LDKRouteHop this_ptr_conv;
41199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41200         this_ptr_conv.is_owned = false;
41201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41202         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41203 }
41204
41205 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) {
41206         LDKPublicKey pubkey_arg_ref;
41207         CHECK(pubkey_arg->arr_len == 33);
41208         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
41209         LDKNodeFeatures node_features_arg_conv;
41210         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41211         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41213         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41214         LDKChannelFeatures channel_features_arg_conv;
41215         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41216         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41217         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41218         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41219         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);
41220         uint32_t ret_ref = 0;
41221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41224         ret_ref = (uintptr_t)ret_var.inner;
41225         if (ret_var.is_owned) {
41226                 ret_ref |= 1;
41227         }
41228         return ret_ref;
41229 }
41230
41231 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41232         LDKRouteHop ret_var = RouteHop_clone(arg);
41233 uint32_t ret_ref = 0;
41234 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41235 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41236 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41237 ret_ref = (uintptr_t)ret_var.inner;
41238 if (ret_var.is_owned) {
41239         ret_ref |= 1;
41240 }
41241         return ret_ref;
41242 }
41243 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
41244         LDKRouteHop arg_conv;
41245         arg_conv.inner = (void*)(arg & (~1));
41246         arg_conv.is_owned = false;
41247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41248         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41249         return ret_conv;
41250 }
41251
41252 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
41253         LDKRouteHop orig_conv;
41254         orig_conv.inner = (void*)(orig & (~1));
41255         orig_conv.is_owned = false;
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41257         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41258         uint32_t ret_ref = 0;
41259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41262         ret_ref = (uintptr_t)ret_var.inner;
41263         if (ret_var.is_owned) {
41264                 ret_ref |= 1;
41265         }
41266         return ret_ref;
41267 }
41268
41269 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
41270         LDKRouteHop o_conv;
41271         o_conv.inner = (void*)(o & (~1));
41272         o_conv.is_owned = false;
41273         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41274         int64_t ret_conv = RouteHop_hash(&o_conv);
41275         return ret_conv;
41276 }
41277
41278 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
41279         LDKRouteHop a_conv;
41280         a_conv.inner = (void*)(a & (~1));
41281         a_conv.is_owned = false;
41282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41283         LDKRouteHop b_conv;
41284         b_conv.inner = (void*)(b & (~1));
41285         b_conv.is_owned = false;
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41287         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41288         return ret_conv;
41289 }
41290
41291 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
41292         LDKRouteHop obj_conv;
41293         obj_conv.inner = (void*)(obj & (~1));
41294         obj_conv.is_owned = false;
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41296         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41297         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41298         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41299         CVec_u8Z_free(ret_var);
41300         return ret_arr;
41301 }
41302
41303 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
41304         LDKu8slice ser_ref;
41305         ser_ref.datalen = ser->arr_len;
41306         ser_ref.data = ser->elems;
41307         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41308         *ret_conv = RouteHop_read(ser_ref);
41309         FREE(ser);
41310         return (uint32_t)ret_conv;
41311 }
41312
41313 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
41314         LDKRoute this_obj_conv;
41315         this_obj_conv.inner = (void*)(this_obj & (~1));
41316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41318         Route_free(this_obj_conv);
41319 }
41320
41321 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
41322         LDKRoute this_ptr_conv;
41323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41324         this_ptr_conv.is_owned = false;
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41326         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41327         ptrArray ret_arr = NULL;
41328         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
41329         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
41330         for (size_t m = 0; m < ret_var.datalen; m++) {
41331                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41332                 uint32_tArray ret_conv_12_arr = NULL;
41333                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
41334                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
41335                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41336                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41337                         uint32_t ret_conv_12_conv_10_ref = 0;
41338                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41339                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41340                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41341                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41342                         if (ret_conv_12_conv_10_var.is_owned) {
41343                                 ret_conv_12_conv_10_ref |= 1;
41344                         }
41345                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41346                 }
41347                 
41348                 FREE(ret_conv_12_var.data);
41349                 ret_arr_ptr[m] = ret_conv_12_arr;
41350         }
41351         
41352         FREE(ret_var.data);
41353         return ret_arr;
41354 }
41355
41356 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
41357         LDKRoute this_ptr_conv;
41358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41359         this_ptr_conv.is_owned = false;
41360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41361         LDKCVec_CVec_RouteHopZZ val_constr;
41362         val_constr.datalen = val->arr_len;
41363         if (val_constr.datalen > 0)
41364                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41365         else
41366                 val_constr.data = NULL;
41367         uint32_tArray* val_vals = (void*) val->elems;
41368         for (size_t m = 0; m < val_constr.datalen; m++) {
41369                 uint32_tArray val_conv_12 = val_vals[m];
41370                 LDKCVec_RouteHopZ val_conv_12_constr;
41371                 val_conv_12_constr.datalen = val_conv_12->arr_len;
41372                 if (val_conv_12_constr.datalen > 0)
41373                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41374                 else
41375                         val_conv_12_constr.data = NULL;
41376                 uint32_t* val_conv_12_vals = val_conv_12->elems;
41377                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41378                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
41379                         LDKRouteHop val_conv_12_conv_10_conv;
41380                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41381                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41382                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41383                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41384                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41385                 }
41386                 FREE(val_conv_12);
41387                 val_constr.data[m] = val_conv_12_constr;
41388         }
41389         FREE(val);
41390         Route_set_paths(&this_ptr_conv, val_constr);
41391 }
41392
41393 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
41394         LDKRoute this_ptr_conv;
41395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41396         this_ptr_conv.is_owned = false;
41397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41398         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41399         uint32_t ret_ref = 0;
41400         if ((uintptr_t)ret_var.inner > 4096) {
41401                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41402                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41404                 ret_ref = (uintptr_t)ret_var.inner;
41405                 if (ret_var.is_owned) {
41406                         ret_ref |= 1;
41407                 }
41408         }
41409         return ret_ref;
41410 }
41411
41412 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
41413         LDKRoute this_ptr_conv;
41414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41415         this_ptr_conv.is_owned = false;
41416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41417         LDKPaymentParameters val_conv;
41418         val_conv.inner = (void*)(val & (~1));
41419         val_conv.is_owned = (val & 1) || (val == 0);
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41421         val_conv = PaymentParameters_clone(&val_conv);
41422         Route_set_payment_params(&this_ptr_conv, val_conv);
41423 }
41424
41425 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
41426         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41427         paths_arg_constr.datalen = paths_arg->arr_len;
41428         if (paths_arg_constr.datalen > 0)
41429                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41430         else
41431                 paths_arg_constr.data = NULL;
41432         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
41433         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41434                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
41435                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41436                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
41437                 if (paths_arg_conv_12_constr.datalen > 0)
41438                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41439                 else
41440                         paths_arg_conv_12_constr.data = NULL;
41441                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
41442                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41443                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41444                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41445                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41446                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41447                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41448                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41449                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41450                 }
41451                 FREE(paths_arg_conv_12);
41452                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41453         }
41454         FREE(paths_arg);
41455         LDKPaymentParameters payment_params_arg_conv;
41456         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41457         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41458         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41459         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41460         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41461         uint32_t ret_ref = 0;
41462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41465         ret_ref = (uintptr_t)ret_var.inner;
41466         if (ret_var.is_owned) {
41467                 ret_ref |= 1;
41468         }
41469         return ret_ref;
41470 }
41471
41472 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41473         LDKRoute ret_var = Route_clone(arg);
41474 uint32_t ret_ref = 0;
41475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41478 ret_ref = (uintptr_t)ret_var.inner;
41479 if (ret_var.is_owned) {
41480         ret_ref |= 1;
41481 }
41482         return ret_ref;
41483 }
41484 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
41485         LDKRoute arg_conv;
41486         arg_conv.inner = (void*)(arg & (~1));
41487         arg_conv.is_owned = false;
41488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41489         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
41490         return ret_conv;
41491 }
41492
41493 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
41494         LDKRoute orig_conv;
41495         orig_conv.inner = (void*)(orig & (~1));
41496         orig_conv.is_owned = false;
41497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41498         LDKRoute ret_var = Route_clone(&orig_conv);
41499         uint32_t ret_ref = 0;
41500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41503         ret_ref = (uintptr_t)ret_var.inner;
41504         if (ret_var.is_owned) {
41505                 ret_ref |= 1;
41506         }
41507         return ret_ref;
41508 }
41509
41510 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
41511         LDKRoute o_conv;
41512         o_conv.inner = (void*)(o & (~1));
41513         o_conv.is_owned = false;
41514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41515         int64_t ret_conv = Route_hash(&o_conv);
41516         return ret_conv;
41517 }
41518
41519 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
41520         LDKRoute a_conv;
41521         a_conv.inner = (void*)(a & (~1));
41522         a_conv.is_owned = false;
41523         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41524         LDKRoute b_conv;
41525         b_conv.inner = (void*)(b & (~1));
41526         b_conv.is_owned = false;
41527         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41528         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41529         return ret_conv;
41530 }
41531
41532 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
41533         LDKRoute this_arg_conv;
41534         this_arg_conv.inner = (void*)(this_arg & (~1));
41535         this_arg_conv.is_owned = false;
41536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41537         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41538         return ret_conv;
41539 }
41540
41541 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
41542         LDKRoute this_arg_conv;
41543         this_arg_conv.inner = (void*)(this_arg & (~1));
41544         this_arg_conv.is_owned = false;
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41546         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41547         return ret_conv;
41548 }
41549
41550 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
41551         LDKRoute obj_conv;
41552         obj_conv.inner = (void*)(obj & (~1));
41553         obj_conv.is_owned = false;
41554         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41555         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41556         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41557         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41558         CVec_u8Z_free(ret_var);
41559         return ret_arr;
41560 }
41561
41562 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
41563         LDKu8slice ser_ref;
41564         ser_ref.datalen = ser->arr_len;
41565         ser_ref.data = ser->elems;
41566         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41567         *ret_conv = Route_read(ser_ref);
41568         FREE(ser);
41569         return (uint32_t)ret_conv;
41570 }
41571
41572 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
41573         LDKRouteParameters this_obj_conv;
41574         this_obj_conv.inner = (void*)(this_obj & (~1));
41575         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41577         RouteParameters_free(this_obj_conv);
41578 }
41579
41580 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
41581         LDKRouteParameters this_ptr_conv;
41582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41583         this_ptr_conv.is_owned = false;
41584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41585         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41586         uint32_t ret_ref = 0;
41587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41590         ret_ref = (uintptr_t)ret_var.inner;
41591         if (ret_var.is_owned) {
41592                 ret_ref |= 1;
41593         }
41594         return ret_ref;
41595 }
41596
41597 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
41598         LDKRouteParameters this_ptr_conv;
41599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41600         this_ptr_conv.is_owned = false;
41601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41602         LDKPaymentParameters val_conv;
41603         val_conv.inner = (void*)(val & (~1));
41604         val_conv.is_owned = (val & 1) || (val == 0);
41605         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41606         val_conv = PaymentParameters_clone(&val_conv);
41607         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41608 }
41609
41610 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
41611         LDKRouteParameters this_ptr_conv;
41612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41613         this_ptr_conv.is_owned = false;
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41615         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
41616         return ret_conv;
41617 }
41618
41619 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
41620         LDKRouteParameters this_ptr_conv;
41621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41622         this_ptr_conv.is_owned = false;
41623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41624         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41625 }
41626
41627 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
41628         LDKRouteParameters this_ptr_conv;
41629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41630         this_ptr_conv.is_owned = false;
41631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41632         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41633         return ret_conv;
41634 }
41635
41636 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) {
41637         LDKRouteParameters this_ptr_conv;
41638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41639         this_ptr_conv.is_owned = false;
41640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41641         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41642 }
41643
41644 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) {
41645         LDKPaymentParameters payment_params_arg_conv;
41646         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41647         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41648         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41649         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41650         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41651         uint32_t ret_ref = 0;
41652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41655         ret_ref = (uintptr_t)ret_var.inner;
41656         if (ret_var.is_owned) {
41657                 ret_ref |= 1;
41658         }
41659         return ret_ref;
41660 }
41661
41662 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41663         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41664 uint32_t ret_ref = 0;
41665 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41666 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41667 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41668 ret_ref = (uintptr_t)ret_var.inner;
41669 if (ret_var.is_owned) {
41670         ret_ref |= 1;
41671 }
41672         return ret_ref;
41673 }
41674 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
41675         LDKRouteParameters arg_conv;
41676         arg_conv.inner = (void*)(arg & (~1));
41677         arg_conv.is_owned = false;
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41679         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
41680         return ret_conv;
41681 }
41682
41683 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
41684         LDKRouteParameters orig_conv;
41685         orig_conv.inner = (void*)(orig & (~1));
41686         orig_conv.is_owned = false;
41687         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41688         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41689         uint32_t ret_ref = 0;
41690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41693         ret_ref = (uintptr_t)ret_var.inner;
41694         if (ret_var.is_owned) {
41695                 ret_ref |= 1;
41696         }
41697         return ret_ref;
41698 }
41699
41700 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
41701         LDKRouteParameters obj_conv;
41702         obj_conv.inner = (void*)(obj & (~1));
41703         obj_conv.is_owned = false;
41704         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41705         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41706         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41707         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41708         CVec_u8Z_free(ret_var);
41709         return ret_arr;
41710 }
41711
41712 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
41713         LDKu8slice ser_ref;
41714         ser_ref.datalen = ser->arr_len;
41715         ser_ref.data = ser->elems;
41716         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41717         *ret_conv = RouteParameters_read(ser_ref);
41718         FREE(ser);
41719         return (uint32_t)ret_conv;
41720 }
41721
41722 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
41723         LDKPaymentParameters this_obj_conv;
41724         this_obj_conv.inner = (void*)(this_obj & (~1));
41725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41727         PaymentParameters_free(this_obj_conv);
41728 }
41729
41730 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
41731         LDKPaymentParameters this_ptr_conv;
41732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41733         this_ptr_conv.is_owned = false;
41734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41735         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41736         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41737         return ret_arr;
41738 }
41739
41740 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
41741         LDKPaymentParameters this_ptr_conv;
41742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41743         this_ptr_conv.is_owned = false;
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41745         LDKPublicKey val_ref;
41746         CHECK(val->arr_len == 33);
41747         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41748         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41749 }
41750
41751 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
41752         LDKPaymentParameters this_ptr_conv;
41753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41754         this_ptr_conv.is_owned = false;
41755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41756         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41757         uint32_t ret_ref = 0;
41758         if ((uintptr_t)ret_var.inner > 4096) {
41759                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41760                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41762                 ret_ref = (uintptr_t)ret_var.inner;
41763                 if (ret_var.is_owned) {
41764                         ret_ref |= 1;
41765                 }
41766         }
41767         return ret_ref;
41768 }
41769
41770 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
41771         LDKPaymentParameters this_ptr_conv;
41772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41773         this_ptr_conv.is_owned = false;
41774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41775         LDKInvoiceFeatures val_conv;
41776         val_conv.inner = (void*)(val & (~1));
41777         val_conv.is_owned = (val & 1) || (val == 0);
41778         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41779         val_conv = InvoiceFeatures_clone(&val_conv);
41780         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41781 }
41782
41783 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
41784         LDKPaymentParameters this_ptr_conv;
41785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41786         this_ptr_conv.is_owned = false;
41787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41788         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41789         uint32_tArray ret_arr = NULL;
41790         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41791         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41792         for (size_t l = 0; l < ret_var.datalen; l++) {
41793                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41794                 uint32_t ret_conv_11_ref = 0;
41795                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41796                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41797                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41798                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41799                 if (ret_conv_11_var.is_owned) {
41800                         ret_conv_11_ref |= 1;
41801                 }
41802                 ret_arr_ptr[l] = ret_conv_11_ref;
41803         }
41804         
41805         FREE(ret_var.data);
41806         return ret_arr;
41807 }
41808
41809 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
41810         LDKPaymentParameters this_ptr_conv;
41811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41812         this_ptr_conv.is_owned = false;
41813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41814         LDKCVec_RouteHintZ val_constr;
41815         val_constr.datalen = val->arr_len;
41816         if (val_constr.datalen > 0)
41817                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41818         else
41819                 val_constr.data = NULL;
41820         uint32_t* val_vals = val->elems;
41821         for (size_t l = 0; l < val_constr.datalen; l++) {
41822                 uint32_t val_conv_11 = val_vals[l];
41823                 LDKRouteHint val_conv_11_conv;
41824                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
41825                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
41826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41827                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41828                 val_constr.data[l] = val_conv_11_conv;
41829         }
41830         FREE(val);
41831         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41832 }
41833
41834 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
41835         LDKPaymentParameters this_ptr_conv;
41836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41837         this_ptr_conv.is_owned = false;
41838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41839         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41840         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41841         uint32_t ret_ref = (uintptr_t)ret_copy;
41842         return ret_ref;
41843 }
41844
41845 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
41846         LDKPaymentParameters this_ptr_conv;
41847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41848         this_ptr_conv.is_owned = false;
41849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41850         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41851         CHECK_ACCESS(val_ptr);
41852         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41853         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41854         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41855 }
41856
41857 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) {
41858         LDKPaymentParameters this_ptr_conv;
41859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41860         this_ptr_conv.is_owned = false;
41861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41862         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41863         return ret_conv;
41864 }
41865
41866 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) {
41867         LDKPaymentParameters this_ptr_conv;
41868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41869         this_ptr_conv.is_owned = false;
41870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41871         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41872 }
41873
41874 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_path_count"))) TS_PaymentParameters_get_max_path_count(uint32_t this_ptr) {
41875         LDKPaymentParameters this_ptr_conv;
41876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41877         this_ptr_conv.is_owned = false;
41878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41879         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
41880         return ret_conv;
41881 }
41882
41883 void  __attribute__((export_name("TS_PaymentParameters_set_max_path_count"))) TS_PaymentParameters_set_max_path_count(uint32_t this_ptr, int8_t val) {
41884         LDKPaymentParameters this_ptr_conv;
41885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41886         this_ptr_conv.is_owned = false;
41887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41888         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
41889 }
41890
41891 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_channel_saturation_power_of_half"))) TS_PaymentParameters_get_max_channel_saturation_power_of_half(uint32_t this_ptr) {
41892         LDKPaymentParameters this_ptr_conv;
41893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41894         this_ptr_conv.is_owned = false;
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41896         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
41897         return ret_conv;
41898 }
41899
41900 void  __attribute__((export_name("TS_PaymentParameters_set_max_channel_saturation_power_of_half"))) TS_PaymentParameters_set_max_channel_saturation_power_of_half(uint32_t this_ptr, int8_t val) {
41901         LDKPaymentParameters this_ptr_conv;
41902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41903         this_ptr_conv.is_owned = false;
41904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41905         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
41906 }
41907
41908 void  __attribute__((export_name("TS_PaymentParameters_set_previously_failed_channels"))) TS_PaymentParameters_set_previously_failed_channels(uint32_t this_ptr, int64_tArray val) {
41909         LDKPaymentParameters this_ptr_conv;
41910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41911         this_ptr_conv.is_owned = false;
41912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41913         LDKCVec_u64Z val_constr;
41914         val_constr.datalen = val->arr_len;
41915         if (val_constr.datalen > 0)
41916                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41917         else
41918                 val_constr.data = NULL;
41919         int64_t* val_vals = val->elems;
41920         for (size_t i = 0; i < val_constr.datalen; i++) {
41921                 int64_t val_conv_8 = val_vals[i];
41922                 val_constr.data[i] = val_conv_8;
41923         }
41924         FREE(val);
41925         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
41926 }
41927
41928 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, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
41929         LDKPublicKey payee_pubkey_arg_ref;
41930         CHECK(payee_pubkey_arg->arr_len == 33);
41931         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
41932         LDKInvoiceFeatures features_arg_conv;
41933         features_arg_conv.inner = (void*)(features_arg & (~1));
41934         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41936         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41937         LDKCVec_RouteHintZ route_hints_arg_constr;
41938         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
41939         if (route_hints_arg_constr.datalen > 0)
41940                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41941         else
41942                 route_hints_arg_constr.data = NULL;
41943         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
41944         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41945                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41946                 LDKRouteHint route_hints_arg_conv_11_conv;
41947                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
41948                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
41949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
41950                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
41951                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
41952         }
41953         FREE(route_hints_arg);
41954         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
41955         CHECK_ACCESS(expiry_time_arg_ptr);
41956         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
41957         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
41958         LDKCVec_u64Z previously_failed_channels_arg_constr;
41959         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
41960         if (previously_failed_channels_arg_constr.datalen > 0)
41961                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41962         else
41963                 previously_failed_channels_arg_constr.data = NULL;
41964         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
41965         for (size_t i = 0; i < previously_failed_channels_arg_constr.datalen; i++) {
41966                 int64_t previously_failed_channels_arg_conv_8 = previously_failed_channels_arg_vals[i];
41967                 previously_failed_channels_arg_constr.data[i] = previously_failed_channels_arg_conv_8;
41968         }
41969         FREE(previously_failed_channels_arg);
41970         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, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
41971         uint32_t ret_ref = 0;
41972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41975         ret_ref = (uintptr_t)ret_var.inner;
41976         if (ret_var.is_owned) {
41977                 ret_ref |= 1;
41978         }
41979         return ret_ref;
41980 }
41981
41982 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
41983         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
41984 uint32_t ret_ref = 0;
41985 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41986 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41987 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41988 ret_ref = (uintptr_t)ret_var.inner;
41989 if (ret_var.is_owned) {
41990         ret_ref |= 1;
41991 }
41992         return ret_ref;
41993 }
41994 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
41995         LDKPaymentParameters arg_conv;
41996         arg_conv.inner = (void*)(arg & (~1));
41997         arg_conv.is_owned = false;
41998         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41999         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42000         return ret_conv;
42001 }
42002
42003 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
42004         LDKPaymentParameters orig_conv;
42005         orig_conv.inner = (void*)(orig & (~1));
42006         orig_conv.is_owned = false;
42007         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42008         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42009         uint32_t ret_ref = 0;
42010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42013         ret_ref = (uintptr_t)ret_var.inner;
42014         if (ret_var.is_owned) {
42015                 ret_ref |= 1;
42016         }
42017         return ret_ref;
42018 }
42019
42020 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
42021         LDKPaymentParameters o_conv;
42022         o_conv.inner = (void*)(o & (~1));
42023         o_conv.is_owned = false;
42024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42025         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42026         return ret_conv;
42027 }
42028
42029 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
42030         LDKPaymentParameters a_conv;
42031         a_conv.inner = (void*)(a & (~1));
42032         a_conv.is_owned = false;
42033         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42034         LDKPaymentParameters b_conv;
42035         b_conv.inner = (void*)(b & (~1));
42036         b_conv.is_owned = false;
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42038         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42039         return ret_conv;
42040 }
42041
42042 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
42043         LDKPaymentParameters obj_conv;
42044         obj_conv.inner = (void*)(obj & (~1));
42045         obj_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42047         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42048         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42049         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42050         CVec_u8Z_free(ret_var);
42051         return ret_arr;
42052 }
42053
42054 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
42055         LDKu8slice ser_ref;
42056         ser_ref.datalen = ser->arr_len;
42057         ser_ref.data = ser->elems;
42058         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42059         *ret_conv = PaymentParameters_read(ser_ref);
42060         FREE(ser);
42061         return (uint32_t)ret_conv;
42062 }
42063
42064 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
42065         LDKPublicKey payee_pubkey_ref;
42066         CHECK(payee_pubkey->arr_len == 33);
42067         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42068         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42069         uint32_t ret_ref = 0;
42070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42073         ret_ref = (uintptr_t)ret_var.inner;
42074         if (ret_var.is_owned) {
42075                 ret_ref |= 1;
42076         }
42077         return ret_ref;
42078 }
42079
42080 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
42081         LDKPublicKey payee_pubkey_ref;
42082         CHECK(payee_pubkey->arr_len == 33);
42083         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42084         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42085         uint32_t ret_ref = 0;
42086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42089         ret_ref = (uintptr_t)ret_var.inner;
42090         if (ret_var.is_owned) {
42091                 ret_ref |= 1;
42092         }
42093         return ret_ref;
42094 }
42095
42096 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
42097         LDKRouteHint this_obj_conv;
42098         this_obj_conv.inner = (void*)(this_obj & (~1));
42099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42101         RouteHint_free(this_obj_conv);
42102 }
42103
42104 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
42105         LDKRouteHint this_ptr_conv;
42106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42107         this_ptr_conv.is_owned = false;
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42109         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42110         uint32_tArray ret_arr = NULL;
42111         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
42112         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
42113         for (size_t o = 0; o < ret_var.datalen; o++) {
42114                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42115                 uint32_t ret_conv_14_ref = 0;
42116                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42117                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42118                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42119                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42120                 if (ret_conv_14_var.is_owned) {
42121                         ret_conv_14_ref |= 1;
42122                 }
42123                 ret_arr_ptr[o] = ret_conv_14_ref;
42124         }
42125         
42126         FREE(ret_var.data);
42127         return ret_arr;
42128 }
42129
42130 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
42131         LDKRouteHint this_ptr_conv;
42132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42133         this_ptr_conv.is_owned = false;
42134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42135         LDKCVec_RouteHintHopZ val_constr;
42136         val_constr.datalen = val->arr_len;
42137         if (val_constr.datalen > 0)
42138                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42139         else
42140                 val_constr.data = NULL;
42141         uint32_t* val_vals = val->elems;
42142         for (size_t o = 0; o < val_constr.datalen; o++) {
42143                 uint32_t val_conv_14 = val_vals[o];
42144                 LDKRouteHintHop val_conv_14_conv;
42145                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42146                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42147                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42148                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42149                 val_constr.data[o] = val_conv_14_conv;
42150         }
42151         FREE(val);
42152         RouteHint_set_a(&this_ptr_conv, val_constr);
42153 }
42154
42155 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
42156         LDKCVec_RouteHintHopZ a_arg_constr;
42157         a_arg_constr.datalen = a_arg->arr_len;
42158         if (a_arg_constr.datalen > 0)
42159                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42160         else
42161                 a_arg_constr.data = NULL;
42162         uint32_t* a_arg_vals = a_arg->elems;
42163         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42164                 uint32_t a_arg_conv_14 = a_arg_vals[o];
42165                 LDKRouteHintHop a_arg_conv_14_conv;
42166                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42167                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42168                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42169                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42170                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42171         }
42172         FREE(a_arg);
42173         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42174         uint32_t ret_ref = 0;
42175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42178         ret_ref = (uintptr_t)ret_var.inner;
42179         if (ret_var.is_owned) {
42180                 ret_ref |= 1;
42181         }
42182         return ret_ref;
42183 }
42184
42185 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42186         LDKRouteHint ret_var = RouteHint_clone(arg);
42187 uint32_t ret_ref = 0;
42188 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42189 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42190 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42191 ret_ref = (uintptr_t)ret_var.inner;
42192 if (ret_var.is_owned) {
42193         ret_ref |= 1;
42194 }
42195         return ret_ref;
42196 }
42197 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
42198         LDKRouteHint arg_conv;
42199         arg_conv.inner = (void*)(arg & (~1));
42200         arg_conv.is_owned = false;
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42202         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42203         return ret_conv;
42204 }
42205
42206 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
42207         LDKRouteHint orig_conv;
42208         orig_conv.inner = (void*)(orig & (~1));
42209         orig_conv.is_owned = false;
42210         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42211         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42212         uint32_t ret_ref = 0;
42213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42216         ret_ref = (uintptr_t)ret_var.inner;
42217         if (ret_var.is_owned) {
42218                 ret_ref |= 1;
42219         }
42220         return ret_ref;
42221 }
42222
42223 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
42224         LDKRouteHint o_conv;
42225         o_conv.inner = (void*)(o & (~1));
42226         o_conv.is_owned = false;
42227         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42228         int64_t ret_conv = RouteHint_hash(&o_conv);
42229         return ret_conv;
42230 }
42231
42232 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
42233         LDKRouteHint a_conv;
42234         a_conv.inner = (void*)(a & (~1));
42235         a_conv.is_owned = false;
42236         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42237         LDKRouteHint b_conv;
42238         b_conv.inner = (void*)(b & (~1));
42239         b_conv.is_owned = false;
42240         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42241         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42242         return ret_conv;
42243 }
42244
42245 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
42246         LDKRouteHint obj_conv;
42247         obj_conv.inner = (void*)(obj & (~1));
42248         obj_conv.is_owned = false;
42249         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42250         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42251         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42252         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42253         CVec_u8Z_free(ret_var);
42254         return ret_arr;
42255 }
42256
42257 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
42258         LDKu8slice ser_ref;
42259         ser_ref.datalen = ser->arr_len;
42260         ser_ref.data = ser->elems;
42261         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42262         *ret_conv = RouteHint_read(ser_ref);
42263         FREE(ser);
42264         return (uint32_t)ret_conv;
42265 }
42266
42267 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
42268         LDKRouteHintHop this_obj_conv;
42269         this_obj_conv.inner = (void*)(this_obj & (~1));
42270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42272         RouteHintHop_free(this_obj_conv);
42273 }
42274
42275 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
42276         LDKRouteHintHop this_ptr_conv;
42277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42278         this_ptr_conv.is_owned = false;
42279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42280         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42281         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
42282         return ret_arr;
42283 }
42284
42285 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
42286         LDKRouteHintHop this_ptr_conv;
42287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42288         this_ptr_conv.is_owned = false;
42289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42290         LDKPublicKey val_ref;
42291         CHECK(val->arr_len == 33);
42292         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42293         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42294 }
42295
42296 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
42297         LDKRouteHintHop this_ptr_conv;
42298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42299         this_ptr_conv.is_owned = false;
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42301         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42302         return ret_conv;
42303 }
42304
42305 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
42306         LDKRouteHintHop this_ptr_conv;
42307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42308         this_ptr_conv.is_owned = false;
42309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42310         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42311 }
42312
42313 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
42314         LDKRouteHintHop this_ptr_conv;
42315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42316         this_ptr_conv.is_owned = false;
42317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42318         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42319         uint32_t ret_ref = 0;
42320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42323         ret_ref = (uintptr_t)ret_var.inner;
42324         if (ret_var.is_owned) {
42325                 ret_ref |= 1;
42326         }
42327         return ret_ref;
42328 }
42329
42330 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
42331         LDKRouteHintHop this_ptr_conv;
42332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42333         this_ptr_conv.is_owned = false;
42334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42335         LDKRoutingFees val_conv;
42336         val_conv.inner = (void*)(val & (~1));
42337         val_conv.is_owned = (val & 1) || (val == 0);
42338         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42339         val_conv = RoutingFees_clone(&val_conv);
42340         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42341 }
42342
42343 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
42344         LDKRouteHintHop this_ptr_conv;
42345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42346         this_ptr_conv.is_owned = false;
42347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42348         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42349         return ret_conv;
42350 }
42351
42352 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
42353         LDKRouteHintHop this_ptr_conv;
42354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42355         this_ptr_conv.is_owned = false;
42356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42357         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42358 }
42359
42360 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
42361         LDKRouteHintHop this_ptr_conv;
42362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42363         this_ptr_conv.is_owned = false;
42364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42365         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42366         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42367         uint32_t ret_ref = (uintptr_t)ret_copy;
42368         return ret_ref;
42369 }
42370
42371 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
42372         LDKRouteHintHop this_ptr_conv;
42373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42374         this_ptr_conv.is_owned = false;
42375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42376         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42377         CHECK_ACCESS(val_ptr);
42378         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42379         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42380         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42381 }
42382
42383 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
42384         LDKRouteHintHop this_ptr_conv;
42385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42386         this_ptr_conv.is_owned = false;
42387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42388         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42389         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42390         uint32_t ret_ref = (uintptr_t)ret_copy;
42391         return ret_ref;
42392 }
42393
42394 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
42395         LDKRouteHintHop this_ptr_conv;
42396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42397         this_ptr_conv.is_owned = false;
42398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42399         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42400         CHECK_ACCESS(val_ptr);
42401         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42402         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42403         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42404 }
42405
42406 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) {
42407         LDKPublicKey src_node_id_arg_ref;
42408         CHECK(src_node_id_arg->arr_len == 33);
42409         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
42410         LDKRoutingFees fees_arg_conv;
42411         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42412         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42413         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42414         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42415         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42416         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42417         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42418         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42419         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42420         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42421         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42422         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42423         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);
42424         uint32_t ret_ref = 0;
42425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42428         ret_ref = (uintptr_t)ret_var.inner;
42429         if (ret_var.is_owned) {
42430                 ret_ref |= 1;
42431         }
42432         return ret_ref;
42433 }
42434
42435 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42436         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42437 uint32_t ret_ref = 0;
42438 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42439 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42440 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42441 ret_ref = (uintptr_t)ret_var.inner;
42442 if (ret_var.is_owned) {
42443         ret_ref |= 1;
42444 }
42445         return ret_ref;
42446 }
42447 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
42448         LDKRouteHintHop arg_conv;
42449         arg_conv.inner = (void*)(arg & (~1));
42450         arg_conv.is_owned = false;
42451         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42452         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42453         return ret_conv;
42454 }
42455
42456 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
42457         LDKRouteHintHop orig_conv;
42458         orig_conv.inner = (void*)(orig & (~1));
42459         orig_conv.is_owned = false;
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42461         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42462         uint32_t ret_ref = 0;
42463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42466         ret_ref = (uintptr_t)ret_var.inner;
42467         if (ret_var.is_owned) {
42468                 ret_ref |= 1;
42469         }
42470         return ret_ref;
42471 }
42472
42473 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
42474         LDKRouteHintHop o_conv;
42475         o_conv.inner = (void*)(o & (~1));
42476         o_conv.is_owned = false;
42477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42478         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42479         return ret_conv;
42480 }
42481
42482 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
42483         LDKRouteHintHop a_conv;
42484         a_conv.inner = (void*)(a & (~1));
42485         a_conv.is_owned = false;
42486         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42487         LDKRouteHintHop b_conv;
42488         b_conv.inner = (void*)(b & (~1));
42489         b_conv.is_owned = false;
42490         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42491         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42492         return ret_conv;
42493 }
42494
42495 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
42496         LDKRouteHintHop obj_conv;
42497         obj_conv.inner = (void*)(obj & (~1));
42498         obj_conv.is_owned = false;
42499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42500         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42501         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42502         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42503         CVec_u8Z_free(ret_var);
42504         return ret_arr;
42505 }
42506
42507 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
42508         LDKu8slice ser_ref;
42509         ser_ref.datalen = ser->arr_len;
42510         ser_ref.data = ser->elems;
42511         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42512         *ret_conv = RouteHintHop_read(ser_ref);
42513         FREE(ser);
42514         return (uint32_t)ret_conv;
42515 }
42516
42517 uint32_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t route_params, uint32_t network_graph, uint32_tArray first_hops, uint32_t logger, uint32_t scorer, int8_tArray random_seed_bytes) {
42518         LDKPublicKey our_node_pubkey_ref;
42519         CHECK(our_node_pubkey->arr_len == 33);
42520         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42521         LDKRouteParameters route_params_conv;
42522         route_params_conv.inner = (void*)(route_params & (~1));
42523         route_params_conv.is_owned = false;
42524         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42525         LDKNetworkGraph network_graph_conv;
42526         network_graph_conv.inner = (void*)(network_graph & (~1));
42527         network_graph_conv.is_owned = false;
42528         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42529         LDKCVec_ChannelDetailsZ first_hops_constr;
42530         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42531         if (first_hops != 0) {
42532                 first_hops_constr.datalen = first_hops->arr_len;
42533                 if (first_hops_constr.datalen > 0)
42534                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42535                 else
42536                         first_hops_constr.data = NULL;
42537                 uint32_t* first_hops_vals = first_hops->elems;
42538                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42539                         uint32_t first_hops_conv_16 = first_hops_vals[q];
42540                         LDKChannelDetails first_hops_conv_16_conv;
42541                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42542                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42543                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42544                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42545                 }
42546                 FREE(first_hops);
42547                 first_hops_ptr = &first_hops_constr;
42548         }
42549         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42550         CHECK_ACCESS(logger_ptr);
42551         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42552         if (logger_conv.free == LDKLogger_JCalls_free) {
42553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42554                 LDKLogger_JCalls_cloned(&logger_conv);
42555         }
42556         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42557         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42558         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42559         unsigned char random_seed_bytes_arr[32];
42560         CHECK(random_seed_bytes->arr_len == 32);
42561         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42562         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42563         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42564         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
42565         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42566         return (uint32_t)ret_conv;
42567 }
42568
42569 uint32_t  __attribute__((export_name("TS_build_route_from_hops"))) TS_build_route_from_hops(int8_tArray our_node_pubkey, ptrArray hops, uint32_t route_params, uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42570         LDKPublicKey our_node_pubkey_ref;
42571         CHECK(our_node_pubkey->arr_len == 33);
42572         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42573         LDKCVec_PublicKeyZ hops_constr;
42574         hops_constr.datalen = hops->arr_len;
42575         if (hops_constr.datalen > 0)
42576                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
42577         else
42578                 hops_constr.data = NULL;
42579         int8_tArray* hops_vals = (void*) hops->elems;
42580         for (size_t m = 0; m < hops_constr.datalen; m++) {
42581                 int8_tArray hops_conv_12 = hops_vals[m];
42582                 LDKPublicKey hops_conv_12_ref;
42583                 CHECK(hops_conv_12->arr_len == 33);
42584                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
42585                 hops_constr.data[m] = hops_conv_12_ref;
42586         }
42587         FREE(hops);
42588         LDKRouteParameters route_params_conv;
42589         route_params_conv.inner = (void*)(route_params & (~1));
42590         route_params_conv.is_owned = false;
42591         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42592         LDKNetworkGraph network_graph_conv;
42593         network_graph_conv.inner = (void*)(network_graph & (~1));
42594         network_graph_conv.is_owned = false;
42595         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42596         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42597         CHECK_ACCESS(logger_ptr);
42598         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42599         if (logger_conv.free == LDKLogger_JCalls_free) {
42600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42601                 LDKLogger_JCalls_cloned(&logger_conv);
42602         }
42603         unsigned char random_seed_bytes_arr[32];
42604         CHECK(random_seed_bytes->arr_len == 32);
42605         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42606         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42607         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42608         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
42609         return (uint32_t)ret_conv;
42610 }
42611
42612 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
42613         if ((this_ptr & 1) != 0) return;
42614         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42615         CHECK_ACCESS(this_ptr_ptr);
42616         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42617         FREE((void*)this_ptr);
42618         Score_free(this_ptr_conv);
42619 }
42620
42621 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
42622         if ((this_ptr & 1) != 0) return;
42623         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42624         CHECK_ACCESS(this_ptr_ptr);
42625         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42626         FREE((void*)this_ptr);
42627         LockableScore_free(this_ptr_conv);
42628 }
42629
42630 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
42631         LDKMultiThreadedLockableScore this_obj_conv;
42632         this_obj_conv.inner = (void*)(this_obj & (~1));
42633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42635         MultiThreadedLockableScore_free(this_obj_conv);
42636 }
42637
42638 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
42639         LDKMultiThreadedLockableScore obj_conv;
42640         obj_conv.inner = (void*)(obj & (~1));
42641         obj_conv.is_owned = false;
42642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42643         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
42644         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42645         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42646         CVec_u8Z_free(ret_var);
42647         return ret_arr;
42648 }
42649
42650 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
42651         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42652         CHECK_ACCESS(score_ptr);
42653         LDKScore score_conv = *(LDKScore*)(score_ptr);
42654         if (score_conv.free == LDKScore_JCalls_free) {
42655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42656                 LDKScore_JCalls_cloned(&score_conv);
42657         }
42658         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42659         uint32_t ret_ref = 0;
42660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42663         ret_ref = (uintptr_t)ret_var.inner;
42664         if (ret_var.is_owned) {
42665                 ret_ref |= 1;
42666         }
42667         return ret_ref;
42668 }
42669
42670 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
42671         LDKChannelUsage this_obj_conv;
42672         this_obj_conv.inner = (void*)(this_obj & (~1));
42673         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42675         ChannelUsage_free(this_obj_conv);
42676 }
42677
42678 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
42679         LDKChannelUsage this_ptr_conv;
42680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42681         this_ptr_conv.is_owned = false;
42682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42683         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
42684         return ret_conv;
42685 }
42686
42687 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
42688         LDKChannelUsage this_ptr_conv;
42689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42690         this_ptr_conv.is_owned = false;
42691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42692         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
42693 }
42694
42695 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
42696         LDKChannelUsage this_ptr_conv;
42697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42698         this_ptr_conv.is_owned = false;
42699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42700         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
42701         return ret_conv;
42702 }
42703
42704 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
42705         LDKChannelUsage this_ptr_conv;
42706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42707         this_ptr_conv.is_owned = false;
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42709         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
42710 }
42711
42712 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
42713         LDKChannelUsage this_ptr_conv;
42714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42715         this_ptr_conv.is_owned = false;
42716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42717         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42718         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
42719         uint32_t ret_ref = (uintptr_t)ret_copy;
42720         return ret_ref;
42721 }
42722
42723 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
42724         LDKChannelUsage this_ptr_conv;
42725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42726         this_ptr_conv.is_owned = false;
42727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42728         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42729         CHECK_ACCESS(val_ptr);
42730         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
42731         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
42732         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
42733 }
42734
42735 uint32_t  __attribute__((export_name("TS_ChannelUsage_new"))) TS_ChannelUsage_new(int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, uint32_t effective_capacity_arg) {
42736         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
42737         CHECK_ACCESS(effective_capacity_arg_ptr);
42738         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
42739         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
42740         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
42741         uint32_t ret_ref = 0;
42742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42745         ret_ref = (uintptr_t)ret_var.inner;
42746         if (ret_var.is_owned) {
42747                 ret_ref |= 1;
42748         }
42749         return ret_ref;
42750 }
42751
42752 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
42753         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
42754 uint32_t ret_ref = 0;
42755 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42756 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42757 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42758 ret_ref = (uintptr_t)ret_var.inner;
42759 if (ret_var.is_owned) {
42760         ret_ref |= 1;
42761 }
42762         return ret_ref;
42763 }
42764 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
42765         LDKChannelUsage arg_conv;
42766         arg_conv.inner = (void*)(arg & (~1));
42767         arg_conv.is_owned = false;
42768         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42769         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
42770         return ret_conv;
42771 }
42772
42773 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
42774         LDKChannelUsage orig_conv;
42775         orig_conv.inner = (void*)(orig & (~1));
42776         orig_conv.is_owned = false;
42777         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42778         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
42779         uint32_t ret_ref = 0;
42780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42783         ret_ref = (uintptr_t)ret_var.inner;
42784         if (ret_var.is_owned) {
42785                 ret_ref |= 1;
42786         }
42787         return ret_ref;
42788 }
42789
42790 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
42791         LDKFixedPenaltyScorer this_obj_conv;
42792         this_obj_conv.inner = (void*)(this_obj & (~1));
42793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42795         FixedPenaltyScorer_free(this_obj_conv);
42796 }
42797
42798 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42799         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42800 uint32_t ret_ref = 0;
42801 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42802 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42803 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42804 ret_ref = (uintptr_t)ret_var.inner;
42805 if (ret_var.is_owned) {
42806         ret_ref |= 1;
42807 }
42808         return ret_ref;
42809 }
42810 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
42811         LDKFixedPenaltyScorer arg_conv;
42812         arg_conv.inner = (void*)(arg & (~1));
42813         arg_conv.is_owned = false;
42814         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42815         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42816         return ret_conv;
42817 }
42818
42819 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
42820         LDKFixedPenaltyScorer orig_conv;
42821         orig_conv.inner = (void*)(orig & (~1));
42822         orig_conv.is_owned = false;
42823         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42824         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42825         uint32_t ret_ref = 0;
42826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42829         ret_ref = (uintptr_t)ret_var.inner;
42830         if (ret_var.is_owned) {
42831                 ret_ref |= 1;
42832         }
42833         return ret_ref;
42834 }
42835
42836 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
42837         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42838         uint32_t ret_ref = 0;
42839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42842         ret_ref = (uintptr_t)ret_var.inner;
42843         if (ret_var.is_owned) {
42844                 ret_ref |= 1;
42845         }
42846         return ret_ref;
42847 }
42848
42849 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
42850         LDKFixedPenaltyScorer this_arg_conv;
42851         this_arg_conv.inner = (void*)(this_arg & (~1));
42852         this_arg_conv.is_owned = false;
42853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42854         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42855         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42856         return (uint32_t)ret_ret;
42857 }
42858
42859 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
42860         LDKFixedPenaltyScorer obj_conv;
42861         obj_conv.inner = (void*)(obj & (~1));
42862         obj_conv.is_owned = false;
42863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42864         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42865         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42866         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42867         CVec_u8Z_free(ret_var);
42868         return ret_arr;
42869 }
42870
42871 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
42872         LDKu8slice ser_ref;
42873         ser_ref.datalen = ser->arr_len;
42874         ser_ref.data = ser->elems;
42875         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42876         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
42877         FREE(ser);
42878         return (uint32_t)ret_conv;
42879 }
42880
42881 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
42882         LDKProbabilisticScorer this_obj_conv;
42883         this_obj_conv.inner = (void*)(this_obj & (~1));
42884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42886         ProbabilisticScorer_free(this_obj_conv);
42887 }
42888
42889 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
42890         LDKProbabilisticScoringParameters this_obj_conv;
42891         this_obj_conv.inner = (void*)(this_obj & (~1));
42892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42894         ProbabilisticScoringParameters_free(this_obj_conv);
42895 }
42896
42897 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
42898         LDKProbabilisticScoringParameters this_ptr_conv;
42899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42900         this_ptr_conv.is_owned = false;
42901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42902         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42903         return ret_conv;
42904 }
42905
42906 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
42907         LDKProbabilisticScoringParameters this_ptr_conv;
42908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42909         this_ptr_conv.is_owned = false;
42910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42911         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42912 }
42913
42914 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(uint32_t this_ptr) {
42915         LDKProbabilisticScoringParameters this_ptr_conv;
42916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42917         this_ptr_conv.is_owned = false;
42918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42919         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
42920         return ret_conv;
42921 }
42922
42923 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(uint32_t this_ptr, int64_t val) {
42924         LDKProbabilisticScoringParameters this_ptr_conv;
42925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42926         this_ptr_conv.is_owned = false;
42927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42928         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
42929 }
42930
42931 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
42932         LDKProbabilisticScoringParameters this_ptr_conv;
42933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42934         this_ptr_conv.is_owned = false;
42935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42936         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
42937         return ret_conv;
42938 }
42939
42940 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) {
42941         LDKProbabilisticScoringParameters this_ptr_conv;
42942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42943         this_ptr_conv.is_owned = false;
42944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42945         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
42946 }
42947
42948 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
42949         LDKProbabilisticScoringParameters this_ptr_conv;
42950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42951         this_ptr_conv.is_owned = false;
42952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42953         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
42954         return ret_conv;
42955 }
42956
42957 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) {
42958         LDKProbabilisticScoringParameters this_ptr_conv;
42959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42960         this_ptr_conv.is_owned = false;
42961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42962         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
42963 }
42964
42965 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(uint32_t this_ptr) {
42966         LDKProbabilisticScoringParameters this_ptr_conv;
42967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42968         this_ptr_conv.is_owned = false;
42969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42970         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
42971         return ret_conv;
42972 }
42973
42974 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(uint32_t this_ptr, int64_t val) {
42975         LDKProbabilisticScoringParameters this_ptr_conv;
42976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42977         this_ptr_conv.is_owned = false;
42978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42979         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
42980 }
42981
42982 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint32_t this_ptr) {
42983         LDKProbabilisticScoringParameters this_ptr_conv;
42984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42985         this_ptr_conv.is_owned = false;
42986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42987         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
42988         return ret_conv;
42989 }
42990
42991 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat(uint32_t this_ptr, int64_t val) {
42992         LDKProbabilisticScoringParameters this_ptr_conv;
42993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42994         this_ptr_conv.is_owned = false;
42995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42996         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
42997 }
42998
42999 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(uint32_t this_ptr) {
43000         LDKProbabilisticScoringParameters this_ptr_conv;
43001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43002         this_ptr_conv.is_owned = false;
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43004         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
43005         return ret_conv;
43006 }
43007
43008 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(uint32_t this_ptr, int64_t val) {
43009         LDKProbabilisticScoringParameters this_ptr_conv;
43010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43011         this_ptr_conv.is_owned = false;
43012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43013         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
43014 }
43015
43016 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43017         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43018 uint32_t ret_ref = 0;
43019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43022 ret_ref = (uintptr_t)ret_var.inner;
43023 if (ret_var.is_owned) {
43024         ret_ref |= 1;
43025 }
43026         return ret_ref;
43027 }
43028 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
43029         LDKProbabilisticScoringParameters arg_conv;
43030         arg_conv.inner = (void*)(arg & (~1));
43031         arg_conv.is_owned = false;
43032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43033         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43034         return ret_conv;
43035 }
43036
43037 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
43038         LDKProbabilisticScoringParameters orig_conv;
43039         orig_conv.inner = (void*)(orig & (~1));
43040         orig_conv.is_owned = false;
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43042         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43043         uint32_t ret_ref = 0;
43044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43047         ret_ref = (uintptr_t)ret_var.inner;
43048         if (ret_var.is_owned) {
43049                 ret_ref |= 1;
43050         }
43051         return ret_ref;
43052 }
43053
43054 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
43055         LDKProbabilisticScoringParameters params_conv;
43056         params_conv.inner = (void*)(params & (~1));
43057         params_conv.is_owned = (params & 1) || (params == 0);
43058         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43059         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43060         LDKNetworkGraph network_graph_conv;
43061         network_graph_conv.inner = (void*)(network_graph & (~1));
43062         network_graph_conv.is_owned = false;
43063         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43064         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43065         CHECK_ACCESS(logger_ptr);
43066         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43067         if (logger_conv.free == LDKLogger_JCalls_free) {
43068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43069                 LDKLogger_JCalls_cloned(&logger_conv);
43070         }
43071         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
43072         uint32_t ret_ref = 0;
43073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43076         ret_ref = (uintptr_t)ret_var.inner;
43077         if (ret_var.is_owned) {
43078                 ret_ref |= 1;
43079         }
43080         return ret_ref;
43081 }
43082
43083 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
43084         LDKProbabilisticScorer this_arg_conv;
43085         this_arg_conv.inner = (void*)(this_arg & (~1));
43086         this_arg_conv.is_owned = false;
43087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43088         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
43089 }
43090
43091 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_estimated_channel_liquidity_range"))) TS_ProbabilisticScorer_estimated_channel_liquidity_range(uint32_t this_arg, int64_t scid, uint32_t target) {
43092         LDKProbabilisticScorer this_arg_conv;
43093         this_arg_conv.inner = (void*)(this_arg & (~1));
43094         this_arg_conv.is_owned = false;
43095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43096         LDKNodeId target_conv;
43097         target_conv.inner = (void*)(target & (~1));
43098         target_conv.is_owned = false;
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
43100         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
43101         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
43102         uint32_t ret_ref = (uintptr_t)ret_copy;
43103         return ret_ref;
43104 }
43105
43106 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint32_t this_arg, uint32_t node_id) {
43107         LDKProbabilisticScorer this_arg_conv;
43108         this_arg_conv.inner = (void*)(this_arg & (~1));
43109         this_arg_conv.is_owned = false;
43110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43111         LDKNodeId node_id_conv;
43112         node_id_conv.inner = (void*)(node_id & (~1));
43113         node_id_conv.is_owned = false;
43114         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43115         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
43116 }
43117
43118 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint32_t this_arg, uint32_t node_id) {
43119         LDKProbabilisticScorer this_arg_conv;
43120         this_arg_conv.inner = (void*)(this_arg & (~1));
43121         this_arg_conv.is_owned = false;
43122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43123         LDKNodeId node_id_conv;
43124         node_id_conv.inner = (void*)(node_id & (~1));
43125         node_id_conv.is_owned = false;
43126         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43127         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
43128 }
43129
43130 void  __attribute__((export_name("TS_ProbabilisticScorer_set_manual_penalty"))) TS_ProbabilisticScorer_set_manual_penalty(uint32_t this_arg, uint32_t node_id, int64_t penalty) {
43131         LDKProbabilisticScorer this_arg_conv;
43132         this_arg_conv.inner = (void*)(this_arg & (~1));
43133         this_arg_conv.is_owned = false;
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43135         LDKNodeId node_id_conv;
43136         node_id_conv.inner = (void*)(node_id & (~1));
43137         node_id_conv.is_owned = false;
43138         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43139         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
43140 }
43141
43142 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_manual_penalty"))) TS_ProbabilisticScorer_remove_manual_penalty(uint32_t this_arg, uint32_t node_id) {
43143         LDKProbabilisticScorer this_arg_conv;
43144         this_arg_conv.inner = (void*)(this_arg & (~1));
43145         this_arg_conv.is_owned = false;
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43147         LDKNodeId node_id_conv;
43148         node_id_conv.inner = (void*)(node_id & (~1));
43149         node_id_conv.is_owned = false;
43150         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43151         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
43152 }
43153
43154 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_manual_penalties"))) TS_ProbabilisticScorer_clear_manual_penalties(uint32_t this_arg) {
43155         LDKProbabilisticScorer this_arg_conv;
43156         this_arg_conv.inner = (void*)(this_arg & (~1));
43157         this_arg_conv.is_owned = false;
43158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43159         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
43160 }
43161
43162 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint32_t this_arg, uint32_tArray node_ids) {
43163         LDKProbabilisticScoringParameters this_arg_conv;
43164         this_arg_conv.inner = (void*)(this_arg & (~1));
43165         this_arg_conv.is_owned = false;
43166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43167         LDKCVec_NodeIdZ node_ids_constr;
43168         node_ids_constr.datalen = node_ids->arr_len;
43169         if (node_ids_constr.datalen > 0)
43170                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
43171         else
43172                 node_ids_constr.data = NULL;
43173         uint32_t* node_ids_vals = node_ids->elems;
43174         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
43175                 uint32_t node_ids_conv_8 = node_ids_vals[i];
43176                 LDKNodeId node_ids_conv_8_conv;
43177                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
43178                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
43179                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
43180                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
43181                 node_ids_constr.data[i] = node_ids_conv_8_conv;
43182         }
43183         FREE(node_ids);
43184         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
43185 }
43186
43187 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
43188         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43189         uint32_t ret_ref = 0;
43190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43193         ret_ref = (uintptr_t)ret_var.inner;
43194         if (ret_var.is_owned) {
43195                 ret_ref |= 1;
43196         }
43197         return ret_ref;
43198 }
43199
43200 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
43201         LDKProbabilisticScorer this_arg_conv;
43202         this_arg_conv.inner = (void*)(this_arg & (~1));
43203         this_arg_conv.is_owned = false;
43204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43205         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43206         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43207         return (uint32_t)ret_ret;
43208 }
43209
43210 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
43211         LDKProbabilisticScorer obj_conv;
43212         obj_conv.inner = (void*)(obj & (~1));
43213         obj_conv.is_owned = false;
43214         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43215         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43216         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43217         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43218         CVec_u8Z_free(ret_var);
43219         return ret_arr;
43220 }
43221
43222 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b, uint32_t arg_c) {
43223         LDKu8slice ser_ref;
43224         ser_ref.datalen = ser->arr_len;
43225         ser_ref.data = ser->elems;
43226         LDKProbabilisticScoringParameters arg_a_conv;
43227         arg_a_conv.inner = (void*)(arg_a & (~1));
43228         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43230         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43231         LDKNetworkGraph arg_b_conv;
43232         arg_b_conv.inner = (void*)(arg_b & (~1));
43233         arg_b_conv.is_owned = false;
43234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43235         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
43236         CHECK_ACCESS(arg_c_ptr);
43237         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
43238         if (arg_c_conv.free == LDKLogger_JCalls_free) {
43239                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43240                 LDKLogger_JCalls_cloned(&arg_c_conv);
43241         }
43242         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43243         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
43244         FREE(ser);
43245         return (uint32_t)ret_conv;
43246 }
43247
43248 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
43249         if ((this_ptr & 1) != 0) return;
43250         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43251         CHECK_ACCESS(this_ptr_ptr);
43252         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43253         FREE((void*)this_ptr);
43254         ParseError_free(this_ptr_conv);
43255 }
43256
43257 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43258         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43259         *ret_copy = ParseError_clone(arg);
43260 uint32_t ret_ref = (uintptr_t)ret_copy;
43261         return ret_ref;
43262 }
43263 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
43264         LDKParseError* arg_conv = (LDKParseError*)arg;
43265         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
43266         return ret_conv;
43267 }
43268
43269 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
43270         LDKParseError* orig_conv = (LDKParseError*)orig;
43271         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43272         *ret_copy = ParseError_clone(orig_conv);
43273         uint32_t ret_ref = (uintptr_t)ret_copy;
43274         return ret_ref;
43275 }
43276
43277 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
43278         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43279         CHECK_ACCESS(a_ptr);
43280         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43281         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43282         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43283         *ret_copy = ParseError_bech32_error(a_conv);
43284         uint32_t ret_ref = (uintptr_t)ret_copy;
43285         return ret_ref;
43286 }
43287
43288 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
43289         
43290         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43291         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43292         uint32_t ret_ref = (uintptr_t)ret_copy;
43293         return ret_ref;
43294 }
43295
43296 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
43297         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
43298         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43299         *ret_copy = ParseError_malformed_signature(a_conv);
43300         uint32_t ret_ref = (uintptr_t)ret_copy;
43301         return ret_ref;
43302 }
43303
43304 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
43305         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43306         *ret_copy = ParseError_bad_prefix();
43307         uint32_t ret_ref = (uintptr_t)ret_copy;
43308         return ret_ref;
43309 }
43310
43311 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
43312         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43313         *ret_copy = ParseError_unknown_currency();
43314         uint32_t ret_ref = (uintptr_t)ret_copy;
43315         return ret_ref;
43316 }
43317
43318 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
43319         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43320         *ret_copy = ParseError_unknown_si_prefix();
43321         uint32_t ret_ref = (uintptr_t)ret_copy;
43322         return ret_ref;
43323 }
43324
43325 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
43326         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43327         *ret_copy = ParseError_malformed_hrp();
43328         uint32_t ret_ref = (uintptr_t)ret_copy;
43329         return ret_ref;
43330 }
43331
43332 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
43333         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43334         *ret_copy = ParseError_too_short_data_part();
43335         uint32_t ret_ref = (uintptr_t)ret_copy;
43336         return ret_ref;
43337 }
43338
43339 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
43340         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43341         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43342         uint32_t ret_ref = (uintptr_t)ret_copy;
43343         return ret_ref;
43344 }
43345
43346 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
43347         
43348         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43349         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43350         uint32_t ret_ref = (uintptr_t)ret_copy;
43351         return ret_ref;
43352 }
43353
43354 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
43355         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43356         *ret_copy = ParseError_padding_error();
43357         uint32_t ret_ref = (uintptr_t)ret_copy;
43358         return ret_ref;
43359 }
43360
43361 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
43362         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43363         *ret_copy = ParseError_integer_overflow_error();
43364         uint32_t ret_ref = (uintptr_t)ret_copy;
43365         return ret_ref;
43366 }
43367
43368 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
43369         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43370         *ret_copy = ParseError_invalid_seg_wit_program_length();
43371         uint32_t ret_ref = (uintptr_t)ret_copy;
43372         return ret_ref;
43373 }
43374
43375 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
43376         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43377         *ret_copy = ParseError_invalid_pub_key_hash_length();
43378         uint32_t ret_ref = (uintptr_t)ret_copy;
43379         return ret_ref;
43380 }
43381
43382 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
43383         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43384         *ret_copy = ParseError_invalid_script_hash_length();
43385         uint32_t ret_ref = (uintptr_t)ret_copy;
43386         return ret_ref;
43387 }
43388
43389 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
43390         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43391         *ret_copy = ParseError_invalid_recovery_id();
43392         uint32_t ret_ref = (uintptr_t)ret_copy;
43393         return ret_ref;
43394 }
43395
43396 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
43397         LDKStr a_conv = str_ref_to_owned_c(a);
43398         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43399         *ret_copy = ParseError_invalid_slice_length(a_conv);
43400         uint32_t ret_ref = (uintptr_t)ret_copy;
43401         return ret_ref;
43402 }
43403
43404 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
43405         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43406         *ret_copy = ParseError_skip();
43407         uint32_t ret_ref = (uintptr_t)ret_copy;
43408         return ret_ref;
43409 }
43410
43411 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
43412         if ((this_ptr & 1) != 0) return;
43413         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43414         CHECK_ACCESS(this_ptr_ptr);
43415         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43416         FREE((void*)this_ptr);
43417         ParseOrSemanticError_free(this_ptr_conv);
43418 }
43419
43420 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43421         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43422         *ret_copy = ParseOrSemanticError_clone(arg);
43423 uint32_t ret_ref = (uintptr_t)ret_copy;
43424         return ret_ref;
43425 }
43426 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
43427         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43428         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43429         return ret_conv;
43430 }
43431
43432 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
43433         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43434         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43435         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43436         uint32_t ret_ref = (uintptr_t)ret_copy;
43437         return ret_ref;
43438 }
43439
43440 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
43441         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43442         CHECK_ACCESS(a_ptr);
43443         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43444         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43445         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43446         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43447         uint32_t ret_ref = (uintptr_t)ret_copy;
43448         return ret_ref;
43449 }
43450
43451 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
43452         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
43453         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43454         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43455         uint32_t ret_ref = (uintptr_t)ret_copy;
43456         return ret_ref;
43457 }
43458
43459 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
43460         LDKInvoice this_obj_conv;
43461         this_obj_conv.inner = (void*)(this_obj & (~1));
43462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43464         Invoice_free(this_obj_conv);
43465 }
43466
43467 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
43468         LDKInvoice a_conv;
43469         a_conv.inner = (void*)(a & (~1));
43470         a_conv.is_owned = false;
43471         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43472         LDKInvoice b_conv;
43473         b_conv.inner = (void*)(b & (~1));
43474         b_conv.is_owned = false;
43475         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43476         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43477         return ret_conv;
43478 }
43479
43480 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43481         LDKInvoice ret_var = Invoice_clone(arg);
43482 uint32_t ret_ref = 0;
43483 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43484 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43485 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43486 ret_ref = (uintptr_t)ret_var.inner;
43487 if (ret_var.is_owned) {
43488         ret_ref |= 1;
43489 }
43490         return ret_ref;
43491 }
43492 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
43493         LDKInvoice arg_conv;
43494         arg_conv.inner = (void*)(arg & (~1));
43495         arg_conv.is_owned = false;
43496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43497         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
43498         return ret_conv;
43499 }
43500
43501 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
43502         LDKInvoice orig_conv;
43503         orig_conv.inner = (void*)(orig & (~1));
43504         orig_conv.is_owned = false;
43505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43506         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43507         uint32_t ret_ref = 0;
43508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43511         ret_ref = (uintptr_t)ret_var.inner;
43512         if (ret_var.is_owned) {
43513                 ret_ref |= 1;
43514         }
43515         return ret_ref;
43516 }
43517
43518 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
43519         LDKSignedRawInvoice this_obj_conv;
43520         this_obj_conv.inner = (void*)(this_obj & (~1));
43521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43523         SignedRawInvoice_free(this_obj_conv);
43524 }
43525
43526 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
43527         LDKSignedRawInvoice a_conv;
43528         a_conv.inner = (void*)(a & (~1));
43529         a_conv.is_owned = false;
43530         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43531         LDKSignedRawInvoice b_conv;
43532         b_conv.inner = (void*)(b & (~1));
43533         b_conv.is_owned = false;
43534         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43535         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43536         return ret_conv;
43537 }
43538
43539 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43540         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43541 uint32_t ret_ref = 0;
43542 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43543 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43544 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43545 ret_ref = (uintptr_t)ret_var.inner;
43546 if (ret_var.is_owned) {
43547         ret_ref |= 1;
43548 }
43549         return ret_ref;
43550 }
43551 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
43552         LDKSignedRawInvoice arg_conv;
43553         arg_conv.inner = (void*)(arg & (~1));
43554         arg_conv.is_owned = false;
43555         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43556         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43557         return ret_conv;
43558 }
43559
43560 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
43561         LDKSignedRawInvoice orig_conv;
43562         orig_conv.inner = (void*)(orig & (~1));
43563         orig_conv.is_owned = false;
43564         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43565         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43566         uint32_t ret_ref = 0;
43567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43570         ret_ref = (uintptr_t)ret_var.inner;
43571         if (ret_var.is_owned) {
43572                 ret_ref |= 1;
43573         }
43574         return ret_ref;
43575 }
43576
43577 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
43578         LDKRawInvoice this_obj_conv;
43579         this_obj_conv.inner = (void*)(this_obj & (~1));
43580         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43582         RawInvoice_free(this_obj_conv);
43583 }
43584
43585 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
43586         LDKRawInvoice this_ptr_conv;
43587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43588         this_ptr_conv.is_owned = false;
43589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43590         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43591         uint32_t ret_ref = 0;
43592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43595         ret_ref = (uintptr_t)ret_var.inner;
43596         if (ret_var.is_owned) {
43597                 ret_ref |= 1;
43598         }
43599         return ret_ref;
43600 }
43601
43602 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
43603         LDKRawInvoice this_ptr_conv;
43604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43605         this_ptr_conv.is_owned = false;
43606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43607         LDKRawDataPart val_conv;
43608         val_conv.inner = (void*)(val & (~1));
43609         val_conv.is_owned = (val & 1) || (val == 0);
43610         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43611         val_conv = RawDataPart_clone(&val_conv);
43612         RawInvoice_set_data(&this_ptr_conv, val_conv);
43613 }
43614
43615 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
43616         LDKRawInvoice a_conv;
43617         a_conv.inner = (void*)(a & (~1));
43618         a_conv.is_owned = false;
43619         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43620         LDKRawInvoice b_conv;
43621         b_conv.inner = (void*)(b & (~1));
43622         b_conv.is_owned = false;
43623         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43624         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
43625         return ret_conv;
43626 }
43627
43628 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43629         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43630 uint32_t ret_ref = 0;
43631 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43632 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43633 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43634 ret_ref = (uintptr_t)ret_var.inner;
43635 if (ret_var.is_owned) {
43636         ret_ref |= 1;
43637 }
43638         return ret_ref;
43639 }
43640 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
43641         LDKRawInvoice arg_conv;
43642         arg_conv.inner = (void*)(arg & (~1));
43643         arg_conv.is_owned = false;
43644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43645         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
43646         return ret_conv;
43647 }
43648
43649 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
43650         LDKRawInvoice orig_conv;
43651         orig_conv.inner = (void*)(orig & (~1));
43652         orig_conv.is_owned = false;
43653         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43654         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
43655         uint32_t ret_ref = 0;
43656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43659         ret_ref = (uintptr_t)ret_var.inner;
43660         if (ret_var.is_owned) {
43661                 ret_ref |= 1;
43662         }
43663         return ret_ref;
43664 }
43665
43666 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
43667         LDKRawDataPart this_obj_conv;
43668         this_obj_conv.inner = (void*)(this_obj & (~1));
43669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43671         RawDataPart_free(this_obj_conv);
43672 }
43673
43674 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
43675         LDKRawDataPart this_ptr_conv;
43676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43677         this_ptr_conv.is_owned = false;
43678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43679         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
43680         uint32_t ret_ref = 0;
43681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43684         ret_ref = (uintptr_t)ret_var.inner;
43685         if (ret_var.is_owned) {
43686                 ret_ref |= 1;
43687         }
43688         return ret_ref;
43689 }
43690
43691 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
43692         LDKRawDataPart this_ptr_conv;
43693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43694         this_ptr_conv.is_owned = false;
43695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43696         LDKPositiveTimestamp val_conv;
43697         val_conv.inner = (void*)(val & (~1));
43698         val_conv.is_owned = (val & 1) || (val == 0);
43699         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43700         val_conv = PositiveTimestamp_clone(&val_conv);
43701         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
43702 }
43703
43704 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
43705         LDKRawDataPart a_conv;
43706         a_conv.inner = (void*)(a & (~1));
43707         a_conv.is_owned = false;
43708         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43709         LDKRawDataPart b_conv;
43710         b_conv.inner = (void*)(b & (~1));
43711         b_conv.is_owned = false;
43712         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43713         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
43714         return ret_conv;
43715 }
43716
43717 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
43718         LDKRawDataPart ret_var = RawDataPart_clone(arg);
43719 uint32_t ret_ref = 0;
43720 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43721 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43722 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43723 ret_ref = (uintptr_t)ret_var.inner;
43724 if (ret_var.is_owned) {
43725         ret_ref |= 1;
43726 }
43727         return ret_ref;
43728 }
43729 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
43730         LDKRawDataPart arg_conv;
43731         arg_conv.inner = (void*)(arg & (~1));
43732         arg_conv.is_owned = false;
43733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43734         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
43735         return ret_conv;
43736 }
43737
43738 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
43739         LDKRawDataPart orig_conv;
43740         orig_conv.inner = (void*)(orig & (~1));
43741         orig_conv.is_owned = false;
43742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43743         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
43744         uint32_t ret_ref = 0;
43745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43748         ret_ref = (uintptr_t)ret_var.inner;
43749         if (ret_var.is_owned) {
43750                 ret_ref |= 1;
43751         }
43752         return ret_ref;
43753 }
43754
43755 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
43756         LDKPositiveTimestamp this_obj_conv;
43757         this_obj_conv.inner = (void*)(this_obj & (~1));
43758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43760         PositiveTimestamp_free(this_obj_conv);
43761 }
43762
43763 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
43764         LDKPositiveTimestamp a_conv;
43765         a_conv.inner = (void*)(a & (~1));
43766         a_conv.is_owned = false;
43767         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43768         LDKPositiveTimestamp b_conv;
43769         b_conv.inner = (void*)(b & (~1));
43770         b_conv.is_owned = false;
43771         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43772         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
43773         return ret_conv;
43774 }
43775
43776 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
43777         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
43778 uint32_t ret_ref = 0;
43779 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43780 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43782 ret_ref = (uintptr_t)ret_var.inner;
43783 if (ret_var.is_owned) {
43784         ret_ref |= 1;
43785 }
43786         return ret_ref;
43787 }
43788 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
43789         LDKPositiveTimestamp arg_conv;
43790         arg_conv.inner = (void*)(arg & (~1));
43791         arg_conv.is_owned = false;
43792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43793         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
43794         return ret_conv;
43795 }
43796
43797 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
43798         LDKPositiveTimestamp orig_conv;
43799         orig_conv.inner = (void*)(orig & (~1));
43800         orig_conv.is_owned = false;
43801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43802         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
43803         uint32_t ret_ref = 0;
43804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43807         ret_ref = (uintptr_t)ret_var.inner;
43808         if (ret_var.is_owned) {
43809                 ret_ref |= 1;
43810         }
43811         return ret_ref;
43812 }
43813
43814 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
43815         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
43816         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
43817         return ret_conv;
43818 }
43819
43820 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
43821         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
43822         return ret_conv;
43823 }
43824
43825 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
43826         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
43827         return ret_conv;
43828 }
43829
43830 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
43831         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
43832         return ret_conv;
43833 }
43834
43835 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
43836         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
43837         return ret_conv;
43838 }
43839
43840 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
43841         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
43842         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
43843         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
43844         return ret_conv;
43845 }
43846
43847 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
43848         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
43849         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
43850         return ret_conv;
43851 }
43852
43853 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
43854         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
43855         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
43856         return ret_conv;
43857 }
43858
43859 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
43860         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
43861         return ret_conv;
43862 }
43863
43864 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
43865         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
43866         return ret_conv;
43867 }
43868
43869 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
43870         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
43871         return ret_conv;
43872 }
43873
43874 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
43875         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
43876         return ret_conv;
43877 }
43878
43879 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
43880         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
43881         return ret_conv;
43882 }
43883
43884 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
43885         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
43886         int64_t ret_conv = Currency_hash(o_conv);
43887         return ret_conv;
43888 }
43889
43890 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
43891         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
43892         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
43893         jboolean ret_conv = Currency_eq(a_conv, b_conv);
43894         return ret_conv;
43895 }
43896
43897 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
43898         LDKSha256 this_obj_conv;
43899         this_obj_conv.inner = (void*)(this_obj & (~1));
43900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43902         Sha256_free(this_obj_conv);
43903 }
43904
43905 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
43906         LDKSha256 ret_var = Sha256_clone(arg);
43907 uint32_t ret_ref = 0;
43908 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43909 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43910 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43911 ret_ref = (uintptr_t)ret_var.inner;
43912 if (ret_var.is_owned) {
43913         ret_ref |= 1;
43914 }
43915         return ret_ref;
43916 }
43917 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
43918         LDKSha256 arg_conv;
43919         arg_conv.inner = (void*)(arg & (~1));
43920         arg_conv.is_owned = false;
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43922         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
43923         return ret_conv;
43924 }
43925
43926 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
43927         LDKSha256 orig_conv;
43928         orig_conv.inner = (void*)(orig & (~1));
43929         orig_conv.is_owned = false;
43930         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43931         LDKSha256 ret_var = Sha256_clone(&orig_conv);
43932         uint32_t ret_ref = 0;
43933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43936         ret_ref = (uintptr_t)ret_var.inner;
43937         if (ret_var.is_owned) {
43938                 ret_ref |= 1;
43939         }
43940         return ret_ref;
43941 }
43942
43943 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
43944         LDKSha256 o_conv;
43945         o_conv.inner = (void*)(o & (~1));
43946         o_conv.is_owned = false;
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43948         int64_t ret_conv = Sha256_hash(&o_conv);
43949         return ret_conv;
43950 }
43951
43952 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
43953         LDKSha256 a_conv;
43954         a_conv.inner = (void*)(a & (~1));
43955         a_conv.is_owned = false;
43956         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43957         LDKSha256 b_conv;
43958         b_conv.inner = (void*)(b & (~1));
43959         b_conv.is_owned = false;
43960         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43961         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
43962         return ret_conv;
43963 }
43964
43965 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
43966         LDKDescription this_obj_conv;
43967         this_obj_conv.inner = (void*)(this_obj & (~1));
43968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43970         Description_free(this_obj_conv);
43971 }
43972
43973 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
43974         LDKDescription ret_var = Description_clone(arg);
43975 uint32_t ret_ref = 0;
43976 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43977 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43978 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43979 ret_ref = (uintptr_t)ret_var.inner;
43980 if (ret_var.is_owned) {
43981         ret_ref |= 1;
43982 }
43983         return ret_ref;
43984 }
43985 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
43986         LDKDescription arg_conv;
43987         arg_conv.inner = (void*)(arg & (~1));
43988         arg_conv.is_owned = false;
43989         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43990         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
43991         return ret_conv;
43992 }
43993
43994 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
43995         LDKDescription orig_conv;
43996         orig_conv.inner = (void*)(orig & (~1));
43997         orig_conv.is_owned = false;
43998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43999         LDKDescription ret_var = Description_clone(&orig_conv);
44000         uint32_t ret_ref = 0;
44001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44004         ret_ref = (uintptr_t)ret_var.inner;
44005         if (ret_var.is_owned) {
44006                 ret_ref |= 1;
44007         }
44008         return ret_ref;
44009 }
44010
44011 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
44012         LDKDescription o_conv;
44013         o_conv.inner = (void*)(o & (~1));
44014         o_conv.is_owned = false;
44015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44016         int64_t ret_conv = Description_hash(&o_conv);
44017         return ret_conv;
44018 }
44019
44020 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
44021         LDKDescription a_conv;
44022         a_conv.inner = (void*)(a & (~1));
44023         a_conv.is_owned = false;
44024         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44025         LDKDescription b_conv;
44026         b_conv.inner = (void*)(b & (~1));
44027         b_conv.is_owned = false;
44028         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44029         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44030         return ret_conv;
44031 }
44032
44033 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
44034         LDKPayeePubKey this_obj_conv;
44035         this_obj_conv.inner = (void*)(this_obj & (~1));
44036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44038         PayeePubKey_free(this_obj_conv);
44039 }
44040
44041 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
44042         LDKPayeePubKey this_ptr_conv;
44043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44044         this_ptr_conv.is_owned = false;
44045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44046         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44047         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
44048         return ret_arr;
44049 }
44050
44051 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
44052         LDKPayeePubKey this_ptr_conv;
44053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44054         this_ptr_conv.is_owned = false;
44055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44056         LDKPublicKey val_ref;
44057         CHECK(val->arr_len == 33);
44058         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
44059         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44060 }
44061
44062 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
44063         LDKPublicKey a_arg_ref;
44064         CHECK(a_arg->arr_len == 33);
44065         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
44066         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44067         uint32_t ret_ref = 0;
44068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44071         ret_ref = (uintptr_t)ret_var.inner;
44072         if (ret_var.is_owned) {
44073                 ret_ref |= 1;
44074         }
44075         return ret_ref;
44076 }
44077
44078 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44079         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44080 uint32_t ret_ref = 0;
44081 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44082 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44083 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44084 ret_ref = (uintptr_t)ret_var.inner;
44085 if (ret_var.is_owned) {
44086         ret_ref |= 1;
44087 }
44088         return ret_ref;
44089 }
44090 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
44091         LDKPayeePubKey arg_conv;
44092         arg_conv.inner = (void*)(arg & (~1));
44093         arg_conv.is_owned = false;
44094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44095         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44096         return ret_conv;
44097 }
44098
44099 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
44100         LDKPayeePubKey orig_conv;
44101         orig_conv.inner = (void*)(orig & (~1));
44102         orig_conv.is_owned = false;
44103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44104         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44105         uint32_t ret_ref = 0;
44106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44109         ret_ref = (uintptr_t)ret_var.inner;
44110         if (ret_var.is_owned) {
44111                 ret_ref |= 1;
44112         }
44113         return ret_ref;
44114 }
44115
44116 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
44117         LDKPayeePubKey o_conv;
44118         o_conv.inner = (void*)(o & (~1));
44119         o_conv.is_owned = false;
44120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44121         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44122         return ret_conv;
44123 }
44124
44125 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
44126         LDKPayeePubKey a_conv;
44127         a_conv.inner = (void*)(a & (~1));
44128         a_conv.is_owned = false;
44129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44130         LDKPayeePubKey b_conv;
44131         b_conv.inner = (void*)(b & (~1));
44132         b_conv.is_owned = false;
44133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44134         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44135         return ret_conv;
44136 }
44137
44138 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
44139         LDKExpiryTime this_obj_conv;
44140         this_obj_conv.inner = (void*)(this_obj & (~1));
44141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44143         ExpiryTime_free(this_obj_conv);
44144 }
44145
44146 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44147         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44148 uint32_t ret_ref = 0;
44149 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44150 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44152 ret_ref = (uintptr_t)ret_var.inner;
44153 if (ret_var.is_owned) {
44154         ret_ref |= 1;
44155 }
44156         return ret_ref;
44157 }
44158 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
44159         LDKExpiryTime arg_conv;
44160         arg_conv.inner = (void*)(arg & (~1));
44161         arg_conv.is_owned = false;
44162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44163         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44164         return ret_conv;
44165 }
44166
44167 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
44168         LDKExpiryTime orig_conv;
44169         orig_conv.inner = (void*)(orig & (~1));
44170         orig_conv.is_owned = false;
44171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44172         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44173         uint32_t ret_ref = 0;
44174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44177         ret_ref = (uintptr_t)ret_var.inner;
44178         if (ret_var.is_owned) {
44179                 ret_ref |= 1;
44180         }
44181         return ret_ref;
44182 }
44183
44184 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
44185         LDKExpiryTime o_conv;
44186         o_conv.inner = (void*)(o & (~1));
44187         o_conv.is_owned = false;
44188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44189         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44190         return ret_conv;
44191 }
44192
44193 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
44194         LDKExpiryTime a_conv;
44195         a_conv.inner = (void*)(a & (~1));
44196         a_conv.is_owned = false;
44197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44198         LDKExpiryTime b_conv;
44199         b_conv.inner = (void*)(b & (~1));
44200         b_conv.is_owned = false;
44201         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44202         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44203         return ret_conv;
44204 }
44205
44206 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
44207         LDKMinFinalCltvExpiry this_obj_conv;
44208         this_obj_conv.inner = (void*)(this_obj & (~1));
44209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44211         MinFinalCltvExpiry_free(this_obj_conv);
44212 }
44213
44214 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
44215         LDKMinFinalCltvExpiry this_ptr_conv;
44216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44217         this_ptr_conv.is_owned = false;
44218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44219         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44220         return ret_conv;
44221 }
44222
44223 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
44224         LDKMinFinalCltvExpiry this_ptr_conv;
44225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44226         this_ptr_conv.is_owned = false;
44227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44228         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44229 }
44230
44231 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
44232         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44233         uint32_t ret_ref = 0;
44234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44237         ret_ref = (uintptr_t)ret_var.inner;
44238         if (ret_var.is_owned) {
44239                 ret_ref |= 1;
44240         }
44241         return ret_ref;
44242 }
44243
44244 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44245         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44246 uint32_t ret_ref = 0;
44247 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44248 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44249 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44250 ret_ref = (uintptr_t)ret_var.inner;
44251 if (ret_var.is_owned) {
44252         ret_ref |= 1;
44253 }
44254         return ret_ref;
44255 }
44256 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
44257         LDKMinFinalCltvExpiry arg_conv;
44258         arg_conv.inner = (void*)(arg & (~1));
44259         arg_conv.is_owned = false;
44260         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44261         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44262         return ret_conv;
44263 }
44264
44265 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
44266         LDKMinFinalCltvExpiry orig_conv;
44267         orig_conv.inner = (void*)(orig & (~1));
44268         orig_conv.is_owned = false;
44269         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44270         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44271         uint32_t ret_ref = 0;
44272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44275         ret_ref = (uintptr_t)ret_var.inner;
44276         if (ret_var.is_owned) {
44277                 ret_ref |= 1;
44278         }
44279         return ret_ref;
44280 }
44281
44282 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
44283         LDKMinFinalCltvExpiry o_conv;
44284         o_conv.inner = (void*)(o & (~1));
44285         o_conv.is_owned = false;
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44287         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44288         return ret_conv;
44289 }
44290
44291 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
44292         LDKMinFinalCltvExpiry a_conv;
44293         a_conv.inner = (void*)(a & (~1));
44294         a_conv.is_owned = false;
44295         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44296         LDKMinFinalCltvExpiry b_conv;
44297         b_conv.inner = (void*)(b & (~1));
44298         b_conv.is_owned = false;
44299         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44300         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44301         return ret_conv;
44302 }
44303
44304 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
44305         if ((this_ptr & 1) != 0) return;
44306         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44307         CHECK_ACCESS(this_ptr_ptr);
44308         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44309         FREE((void*)this_ptr);
44310         Fallback_free(this_ptr_conv);
44311 }
44312
44313 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44314         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44315         *ret_copy = Fallback_clone(arg);
44316 uint32_t ret_ref = (uintptr_t)ret_copy;
44317         return ret_ref;
44318 }
44319 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
44320         LDKFallback* arg_conv = (LDKFallback*)arg;
44321         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
44322         return ret_conv;
44323 }
44324
44325 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
44326         LDKFallback* orig_conv = (LDKFallback*)orig;
44327         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44328         *ret_copy = Fallback_clone(orig_conv);
44329         uint32_t ret_ref = (uintptr_t)ret_copy;
44330         return ret_ref;
44331 }
44332
44333 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
44334         
44335         LDKCVec_u8Z program_ref;
44336         program_ref.datalen = program->arr_len;
44337         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44338         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
44339         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44340         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44341         uint32_t ret_ref = (uintptr_t)ret_copy;
44342         return ret_ref;
44343 }
44344
44345 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
44346         LDKTwentyBytes a_ref;
44347         CHECK(a->arr_len == 20);
44348         memcpy(a_ref.data, a->elems, 20); FREE(a);
44349         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44350         *ret_copy = Fallback_pub_key_hash(a_ref);
44351         uint32_t ret_ref = (uintptr_t)ret_copy;
44352         return ret_ref;
44353 }
44354
44355 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
44356         LDKTwentyBytes a_ref;
44357         CHECK(a->arr_len == 20);
44358         memcpy(a_ref.data, a->elems, 20); FREE(a);
44359         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44360         *ret_copy = Fallback_script_hash(a_ref);
44361         uint32_t ret_ref = (uintptr_t)ret_copy;
44362         return ret_ref;
44363 }
44364
44365 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
44366         LDKFallback* o_conv = (LDKFallback*)o;
44367         int64_t ret_conv = Fallback_hash(o_conv);
44368         return ret_conv;
44369 }
44370
44371 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
44372         LDKFallback* a_conv = (LDKFallback*)a;
44373         LDKFallback* b_conv = (LDKFallback*)b;
44374         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44375         return ret_conv;
44376 }
44377
44378 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
44379         LDKInvoiceSignature this_obj_conv;
44380         this_obj_conv.inner = (void*)(this_obj & (~1));
44381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44383         InvoiceSignature_free(this_obj_conv);
44384 }
44385
44386 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44387         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44388 uint32_t ret_ref = 0;
44389 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44390 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44391 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44392 ret_ref = (uintptr_t)ret_var.inner;
44393 if (ret_var.is_owned) {
44394         ret_ref |= 1;
44395 }
44396         return ret_ref;
44397 }
44398 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
44399         LDKInvoiceSignature arg_conv;
44400         arg_conv.inner = (void*)(arg & (~1));
44401         arg_conv.is_owned = false;
44402         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44403         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44404         return ret_conv;
44405 }
44406
44407 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
44408         LDKInvoiceSignature orig_conv;
44409         orig_conv.inner = (void*)(orig & (~1));
44410         orig_conv.is_owned = false;
44411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44412         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44413         uint32_t ret_ref = 0;
44414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44417         ret_ref = (uintptr_t)ret_var.inner;
44418         if (ret_var.is_owned) {
44419                 ret_ref |= 1;
44420         }
44421         return ret_ref;
44422 }
44423
44424 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
44425         LDKInvoiceSignature a_conv;
44426         a_conv.inner = (void*)(a & (~1));
44427         a_conv.is_owned = false;
44428         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44429         LDKInvoiceSignature b_conv;
44430         b_conv.inner = (void*)(b & (~1));
44431         b_conv.is_owned = false;
44432         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44433         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44434         return ret_conv;
44435 }
44436
44437 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
44438         LDKPrivateRoute this_obj_conv;
44439         this_obj_conv.inner = (void*)(this_obj & (~1));
44440         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44442         PrivateRoute_free(this_obj_conv);
44443 }
44444
44445 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44446         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44447 uint32_t ret_ref = 0;
44448 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44449 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44451 ret_ref = (uintptr_t)ret_var.inner;
44452 if (ret_var.is_owned) {
44453         ret_ref |= 1;
44454 }
44455         return ret_ref;
44456 }
44457 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
44458         LDKPrivateRoute arg_conv;
44459         arg_conv.inner = (void*)(arg & (~1));
44460         arg_conv.is_owned = false;
44461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44462         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44463         return ret_conv;
44464 }
44465
44466 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
44467         LDKPrivateRoute orig_conv;
44468         orig_conv.inner = (void*)(orig & (~1));
44469         orig_conv.is_owned = false;
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44471         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44472         uint32_t ret_ref = 0;
44473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44476         ret_ref = (uintptr_t)ret_var.inner;
44477         if (ret_var.is_owned) {
44478                 ret_ref |= 1;
44479         }
44480         return ret_ref;
44481 }
44482
44483 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
44484         LDKPrivateRoute o_conv;
44485         o_conv.inner = (void*)(o & (~1));
44486         o_conv.is_owned = false;
44487         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44488         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44489         return ret_conv;
44490 }
44491
44492 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
44493         LDKPrivateRoute a_conv;
44494         a_conv.inner = (void*)(a & (~1));
44495         a_conv.is_owned = false;
44496         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44497         LDKPrivateRoute b_conv;
44498         b_conv.inner = (void*)(b & (~1));
44499         b_conv.is_owned = false;
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44501         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44502         return ret_conv;
44503 }
44504
44505 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
44506         LDKSignedRawInvoice this_arg_conv;
44507         this_arg_conv.inner = (void*)(this_arg & (~1));
44508         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44510         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44511         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44512         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44513         return ((uint32_t)ret_conv);
44514 }
44515
44516 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
44517         LDKSignedRawInvoice this_arg_conv;
44518         this_arg_conv.inner = (void*)(this_arg & (~1));
44519         this_arg_conv.is_owned = false;
44520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44521         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44522         uint32_t ret_ref = 0;
44523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44526         ret_ref = (uintptr_t)ret_var.inner;
44527         if (ret_var.is_owned) {
44528                 ret_ref |= 1;
44529         }
44530         return ret_ref;
44531 }
44532
44533 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
44534         LDKSignedRawInvoice this_arg_conv;
44535         this_arg_conv.inner = (void*)(this_arg & (~1));
44536         this_arg_conv.is_owned = false;
44537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44538         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44539         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
44540         return ret_arr;
44541 }
44542
44543 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
44544         LDKSignedRawInvoice this_arg_conv;
44545         this_arg_conv.inner = (void*)(this_arg & (~1));
44546         this_arg_conv.is_owned = false;
44547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44548         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44549         uint32_t ret_ref = 0;
44550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44553         ret_ref = (uintptr_t)ret_var.inner;
44554         if (ret_var.is_owned) {
44555                 ret_ref |= 1;
44556         }
44557         return ret_ref;
44558 }
44559
44560 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
44561         LDKSignedRawInvoice this_arg_conv;
44562         this_arg_conv.inner = (void*)(this_arg & (~1));
44563         this_arg_conv.is_owned = false;
44564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44565         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44566         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44567         return (uint32_t)ret_conv;
44568 }
44569
44570 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
44571         LDKSignedRawInvoice this_arg_conv;
44572         this_arg_conv.inner = (void*)(this_arg & (~1));
44573         this_arg_conv.is_owned = false;
44574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44575         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44576         return ret_conv;
44577 }
44578
44579 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
44580         LDKRawInvoice this_arg_conv;
44581         this_arg_conv.inner = (void*)(this_arg & (~1));
44582         this_arg_conv.is_owned = false;
44583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44584         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44585         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
44586         return ret_arr;
44587 }
44588
44589 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
44590         LDKRawInvoice this_arg_conv;
44591         this_arg_conv.inner = (void*)(this_arg & (~1));
44592         this_arg_conv.is_owned = false;
44593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44594         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44595         uint32_t ret_ref = 0;
44596         if ((uintptr_t)ret_var.inner > 4096) {
44597                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44598                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44600                 ret_ref = (uintptr_t)ret_var.inner;
44601                 if (ret_var.is_owned) {
44602                         ret_ref |= 1;
44603                 }
44604         }
44605         return ret_ref;
44606 }
44607
44608 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
44609         LDKRawInvoice this_arg_conv;
44610         this_arg_conv.inner = (void*)(this_arg & (~1));
44611         this_arg_conv.is_owned = false;
44612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44613         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44614         uint32_t ret_ref = 0;
44615         if ((uintptr_t)ret_var.inner > 4096) {
44616                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44617                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44619                 ret_ref = (uintptr_t)ret_var.inner;
44620                 if (ret_var.is_owned) {
44621                         ret_ref |= 1;
44622                 }
44623         }
44624         return ret_ref;
44625 }
44626
44627 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
44628         LDKRawInvoice this_arg_conv;
44629         this_arg_conv.inner = (void*)(this_arg & (~1));
44630         this_arg_conv.is_owned = false;
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44632         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44633         uint32_t ret_ref = 0;
44634         if ((uintptr_t)ret_var.inner > 4096) {
44635                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44636                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44638                 ret_ref = (uintptr_t)ret_var.inner;
44639                 if (ret_var.is_owned) {
44640                         ret_ref |= 1;
44641                 }
44642         }
44643         return ret_ref;
44644 }
44645
44646 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
44647         LDKRawInvoice this_arg_conv;
44648         this_arg_conv.inner = (void*)(this_arg & (~1));
44649         this_arg_conv.is_owned = false;
44650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44651         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44652         uint32_t ret_ref = 0;
44653         if ((uintptr_t)ret_var.inner > 4096) {
44654                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44655                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44657                 ret_ref = (uintptr_t)ret_var.inner;
44658                 if (ret_var.is_owned) {
44659                         ret_ref |= 1;
44660                 }
44661         }
44662         return ret_ref;
44663 }
44664
44665 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
44666         LDKRawInvoice this_arg_conv;
44667         this_arg_conv.inner = (void*)(this_arg & (~1));
44668         this_arg_conv.is_owned = false;
44669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44670         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44671         uint32_t ret_ref = 0;
44672         if ((uintptr_t)ret_var.inner > 4096) {
44673                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44674                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44676                 ret_ref = (uintptr_t)ret_var.inner;
44677                 if (ret_var.is_owned) {
44678                         ret_ref |= 1;
44679                 }
44680         }
44681         return ret_ref;
44682 }
44683
44684 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
44685         LDKRawInvoice this_arg_conv;
44686         this_arg_conv.inner = (void*)(this_arg & (~1));
44687         this_arg_conv.is_owned = false;
44688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44689         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44690         uint32_t ret_ref = 0;
44691         if ((uintptr_t)ret_var.inner > 4096) {
44692                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44693                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44695                 ret_ref = (uintptr_t)ret_var.inner;
44696                 if (ret_var.is_owned) {
44697                         ret_ref |= 1;
44698                 }
44699         }
44700         return ret_ref;
44701 }
44702
44703 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
44704         LDKRawInvoice this_arg_conv;
44705         this_arg_conv.inner = (void*)(this_arg & (~1));
44706         this_arg_conv.is_owned = false;
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44708         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44709         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
44710         return ret_arr;
44711 }
44712
44713 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
44714         LDKRawInvoice this_arg_conv;
44715         this_arg_conv.inner = (void*)(this_arg & (~1));
44716         this_arg_conv.is_owned = false;
44717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44718         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
44719         uint32_t ret_ref = 0;
44720         if ((uintptr_t)ret_var.inner > 4096) {
44721                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44722                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44724                 ret_ref = (uintptr_t)ret_var.inner;
44725                 if (ret_var.is_owned) {
44726                         ret_ref |= 1;
44727                 }
44728         }
44729         return ret_ref;
44730 }
44731
44732 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
44733         LDKRawInvoice this_arg_conv;
44734         this_arg_conv.inner = (void*)(this_arg & (~1));
44735         this_arg_conv.is_owned = false;
44736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44737         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
44738         uint32_tArray ret_arr = NULL;
44739         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44740         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44741         for (size_t o = 0; o < ret_var.datalen; o++) {
44742                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44743                 uint32_t ret_conv_14_ref = 0;
44744                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44745                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44746                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44747                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44748                 if (ret_conv_14_var.is_owned) {
44749                         ret_conv_14_ref |= 1;
44750                 }
44751                 ret_arr_ptr[o] = ret_conv_14_ref;
44752         }
44753         
44754         FREE(ret_var.data);
44755         return ret_arr;
44756 }
44757
44758 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
44759         LDKRawInvoice this_arg_conv;
44760         this_arg_conv.inner = (void*)(this_arg & (~1));
44761         this_arg_conv.is_owned = false;
44762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44763         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44764         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
44765         uint32_t ret_ref = (uintptr_t)ret_copy;
44766         return ret_ref;
44767 }
44768
44769 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
44770         LDKRawInvoice this_arg_conv;
44771         this_arg_conv.inner = (void*)(this_arg & (~1));
44772         this_arg_conv.is_owned = false;
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44774         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
44775         return ret_conv;
44776 }
44777
44778 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
44779         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44780         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
44781         return (uint32_t)ret_conv;
44782 }
44783
44784 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
44785         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44786         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
44787         return (uint32_t)ret_conv;
44788 }
44789
44790 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
44791         LDKPositiveTimestamp this_arg_conv;
44792         this_arg_conv.inner = (void*)(this_arg & (~1));
44793         this_arg_conv.is_owned = false;
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44795         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
44796         return ret_conv;
44797 }
44798
44799 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
44800         LDKPositiveTimestamp this_arg_conv;
44801         this_arg_conv.inner = (void*)(this_arg & (~1));
44802         this_arg_conv.is_owned = false;
44803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44804         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
44805         return ret_conv;
44806 }
44807
44808 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
44809         LDKInvoice this_arg_conv;
44810         this_arg_conv.inner = (void*)(this_arg & (~1));
44811         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44813         this_arg_conv = Invoice_clone(&this_arg_conv);
44814         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
44815         uint32_t ret_ref = 0;
44816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44819         ret_ref = (uintptr_t)ret_var.inner;
44820         if (ret_var.is_owned) {
44821                 ret_ref |= 1;
44822         }
44823         return ret_ref;
44824 }
44825
44826 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
44827         LDKInvoice this_arg_conv;
44828         this_arg_conv.inner = (void*)(this_arg & (~1));
44829         this_arg_conv.is_owned = false;
44830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44831         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
44832         *ret_conv = Invoice_check_signature(&this_arg_conv);
44833         return (uint32_t)ret_conv;
44834 }
44835
44836 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
44837         LDKSignedRawInvoice signed_invoice_conv;
44838         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
44839         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
44840         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
44841         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
44842         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
44843         *ret_conv = Invoice_from_signed(signed_invoice_conv);
44844         return (uint32_t)ret_conv;
44845 }
44846
44847 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
44848         LDKInvoice this_arg_conv;
44849         this_arg_conv.inner = (void*)(this_arg & (~1));
44850         this_arg_conv.is_owned = false;
44851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44852         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
44853         return ret_conv;
44854 }
44855
44856 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
44857         LDKInvoice this_arg_conv;
44858         this_arg_conv.inner = (void*)(this_arg & (~1));
44859         this_arg_conv.is_owned = false;
44860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44861         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44862         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
44863         return ret_arr;
44864 }
44865
44866 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
44867         LDKInvoice this_arg_conv;
44868         this_arg_conv.inner = (void*)(this_arg & (~1));
44869         this_arg_conv.is_owned = false;
44870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44871         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44872         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
44873         return ret_arr;
44874 }
44875
44876 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
44877         LDKInvoice this_arg_conv;
44878         this_arg_conv.inner = (void*)(this_arg & (~1));
44879         this_arg_conv.is_owned = false;
44880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44881         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44882         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
44883         return ret_arr;
44884 }
44885
44886 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
44887         LDKInvoice this_arg_conv;
44888         this_arg_conv.inner = (void*)(this_arg & (~1));
44889         this_arg_conv.is_owned = false;
44890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44891         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
44892         uint32_t ret_ref = 0;
44893         if ((uintptr_t)ret_var.inner > 4096) {
44894                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44895                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44897                 ret_ref = (uintptr_t)ret_var.inner;
44898                 if (ret_var.is_owned) {
44899                         ret_ref |= 1;
44900                 }
44901         }
44902         return ret_ref;
44903 }
44904
44905 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
44906         LDKInvoice this_arg_conv;
44907         this_arg_conv.inner = (void*)(this_arg & (~1));
44908         this_arg_conv.is_owned = false;
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44910         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44911         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
44912         return ret_arr;
44913 }
44914
44915 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
44916         LDKInvoice this_arg_conv;
44917         this_arg_conv.inner = (void*)(this_arg & (~1));
44918         this_arg_conv.is_owned = false;
44919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44920         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
44921         return ret_conv;
44922 }
44923
44924 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
44925         LDKInvoice this_arg_conv;
44926         this_arg_conv.inner = (void*)(this_arg & (~1));
44927         this_arg_conv.is_owned = false;
44928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44929         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
44930         return ret_conv;
44931 }
44932
44933 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
44934         LDKInvoice this_arg_conv;
44935         this_arg_conv.inner = (void*)(this_arg & (~1));
44936         this_arg_conv.is_owned = false;
44937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44938         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
44939         return ret_conv;
44940 }
44941
44942 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
44943         LDKInvoice this_arg_conv;
44944         this_arg_conv.inner = (void*)(this_arg & (~1));
44945         this_arg_conv.is_owned = false;
44946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44947         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
44948         uint32_tArray ret_arr = NULL;
44949         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44950         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44951         for (size_t o = 0; o < ret_var.datalen; o++) {
44952                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44953                 uint32_t ret_conv_14_ref = 0;
44954                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44955                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44957                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44958                 if (ret_conv_14_var.is_owned) {
44959                         ret_conv_14_ref |= 1;
44960                 }
44961                 ret_arr_ptr[o] = ret_conv_14_ref;
44962         }
44963         
44964         FREE(ret_var.data);
44965         return ret_arr;
44966 }
44967
44968 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
44969         LDKInvoice this_arg_conv;
44970         this_arg_conv.inner = (void*)(this_arg & (~1));
44971         this_arg_conv.is_owned = false;
44972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44973         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
44974         uint32_tArray ret_arr = NULL;
44975         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44976         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44977         for (size_t l = 0; l < ret_var.datalen; l++) {
44978                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44979                 uint32_t ret_conv_11_ref = 0;
44980                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44981                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44982                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44983                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44984                 if (ret_conv_11_var.is_owned) {
44985                         ret_conv_11_ref |= 1;
44986                 }
44987                 ret_arr_ptr[l] = ret_conv_11_ref;
44988         }
44989         
44990         FREE(ret_var.data);
44991         return ret_arr;
44992 }
44993
44994 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
44995         LDKInvoice this_arg_conv;
44996         this_arg_conv.inner = (void*)(this_arg & (~1));
44997         this_arg_conv.is_owned = false;
44998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44999         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
45000         return ret_conv;
45001 }
45002
45003 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
45004         LDKInvoice this_arg_conv;
45005         this_arg_conv.inner = (void*)(this_arg & (~1));
45006         this_arg_conv.is_owned = false;
45007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45008         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45009         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45010         uint32_t ret_ref = (uintptr_t)ret_copy;
45011         return ret_ref;
45012 }
45013
45014 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
45015         LDKStr description_conv = str_ref_to_owned_c(description);
45016         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45017         *ret_conv = Description_new(description_conv);
45018         return (uint32_t)ret_conv;
45019 }
45020
45021 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
45022         LDKDescription this_arg_conv;
45023         this_arg_conv.inner = (void*)(this_arg & (~1));
45024         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45026         this_arg_conv = Description_clone(&this_arg_conv);
45027         LDKStr ret_str = Description_into_inner(this_arg_conv);
45028         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45029         Str_free(ret_str);
45030         return ret_conv;
45031 }
45032
45033 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
45034         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45035         uint32_t ret_ref = 0;
45036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45039         ret_ref = (uintptr_t)ret_var.inner;
45040         if (ret_var.is_owned) {
45041                 ret_ref |= 1;
45042         }
45043         return ret_ref;
45044 }
45045
45046 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
45047         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45048         uint32_t ret_ref = 0;
45049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45052         ret_ref = (uintptr_t)ret_var.inner;
45053         if (ret_var.is_owned) {
45054                 ret_ref |= 1;
45055         }
45056         return ret_ref;
45057 }
45058
45059 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
45060         LDKExpiryTime this_arg_conv;
45061         this_arg_conv.inner = (void*)(this_arg & (~1));
45062         this_arg_conv.is_owned = false;
45063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45064         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45065         return ret_conv;
45066 }
45067
45068 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
45069         LDKExpiryTime this_arg_conv;
45070         this_arg_conv.inner = (void*)(this_arg & (~1));
45071         this_arg_conv.is_owned = false;
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45073         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45074         return ret_conv;
45075 }
45076
45077 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
45078         LDKRouteHint hops_conv;
45079         hops_conv.inner = (void*)(hops & (~1));
45080         hops_conv.is_owned = (hops & 1) || (hops == 0);
45081         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45082         hops_conv = RouteHint_clone(&hops_conv);
45083         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45084         *ret_conv = PrivateRoute_new(hops_conv);
45085         return (uint32_t)ret_conv;
45086 }
45087
45088 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
45089         LDKPrivateRoute this_arg_conv;
45090         this_arg_conv.inner = (void*)(this_arg & (~1));
45091         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45093         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45094         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45095         uint32_t ret_ref = 0;
45096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45099         ret_ref = (uintptr_t)ret_var.inner;
45100         if (ret_var.is_owned) {
45101                 ret_ref |= 1;
45102         }
45103         return ret_ref;
45104 }
45105
45106 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
45107         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45108         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
45109         return ret_conv;
45110 }
45111
45112 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
45113         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
45114         return ret_conv;
45115 }
45116
45117 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
45118         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
45119         return ret_conv;
45120 }
45121
45122 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
45123         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
45124         return ret_conv;
45125 }
45126
45127 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
45128         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
45129         return ret_conv;
45130 }
45131
45132 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
45133         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
45134         return ret_conv;
45135 }
45136
45137 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
45138         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45139         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45140         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45141         return ret_conv;
45142 }
45143
45144 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
45145         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45146         LDKStr ret_str = CreationError_to_str(o_conv);
45147         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45148         Str_free(ret_str);
45149         return ret_conv;
45150 }
45151
45152 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
45153         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45154         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
45155         return ret_conv;
45156 }
45157
45158 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
45159         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
45160         return ret_conv;
45161 }
45162
45163 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
45164         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
45165         return ret_conv;
45166 }
45167
45168 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
45169         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
45170         return ret_conv;
45171 }
45172
45173 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
45174         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
45175         return ret_conv;
45176 }
45177
45178 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
45179         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
45180         return ret_conv;
45181 }
45182
45183 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
45184         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
45185         return ret_conv;
45186 }
45187
45188 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
45189         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
45190         return ret_conv;
45191 }
45192
45193 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
45194         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
45195         return ret_conv;
45196 }
45197
45198 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
45199         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
45200         return ret_conv;
45201 }
45202
45203 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
45204         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
45205         return ret_conv;
45206 }
45207
45208 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
45209         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45210         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45211         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45212         return ret_conv;
45213 }
45214
45215 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
45216         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45217         LDKStr ret_str = SemanticError_to_str(o_conv);
45218         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45219         Str_free(ret_str);
45220         return ret_conv;
45221 }
45222
45223 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
45224         if ((this_ptr & 1) != 0) return;
45225         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45226         CHECK_ACCESS(this_ptr_ptr);
45227         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45228         FREE((void*)this_ptr);
45229         SignOrCreationError_free(this_ptr_conv);
45230 }
45231
45232 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45233         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45234         *ret_copy = SignOrCreationError_clone(arg);
45235 uint32_t ret_ref = (uintptr_t)ret_copy;
45236         return ret_ref;
45237 }
45238 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
45239         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45240         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45241         return ret_conv;
45242 }
45243
45244 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
45245         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45246         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45247         *ret_copy = SignOrCreationError_clone(orig_conv);
45248         uint32_t ret_ref = (uintptr_t)ret_copy;
45249         return ret_ref;
45250 }
45251
45252 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
45253         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45254         *ret_copy = SignOrCreationError_sign_error();
45255         uint32_t ret_ref = (uintptr_t)ret_copy;
45256         return ret_ref;
45257 }
45258
45259 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
45260         LDKCreationError a_conv = LDKCreationError_from_js(a);
45261         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45262         *ret_copy = SignOrCreationError_creation_error(a_conv);
45263         uint32_t ret_ref = (uintptr_t)ret_copy;
45264         return ret_ref;
45265 }
45266
45267 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
45268         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45269         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45270         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45271         return ret_conv;
45272 }
45273
45274 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
45275         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45276         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45277         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45278         Str_free(ret_str);
45279         return ret_conv;
45280 }
45281
45282 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
45283         LDKInvoicePayer this_obj_conv;
45284         this_obj_conv.inner = (void*)(this_obj & (~1));
45285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45287         InvoicePayer_free(this_obj_conv);
45288 }
45289
45290 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
45291         if ((this_ptr & 1) != 0) return;
45292         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45293         CHECK_ACCESS(this_ptr_ptr);
45294         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45295         FREE((void*)this_ptr);
45296         Payer_free(this_ptr_conv);
45297 }
45298
45299 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
45300         if ((this_ptr & 1) != 0) return;
45301         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45302         CHECK_ACCESS(this_ptr_ptr);
45303         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45304         FREE((void*)this_ptr);
45305         Router_free(this_ptr_conv);
45306 }
45307
45308 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
45309         if ((this_ptr & 1) != 0) return;
45310         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45311         CHECK_ACCESS(this_ptr_ptr);
45312         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
45313         FREE((void*)this_ptr);
45314         Retry_free(this_ptr_conv);
45315 }
45316
45317 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
45318         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45319         *ret_copy = Retry_clone(arg);
45320 uint32_t ret_ref = (uintptr_t)ret_copy;
45321         return ret_ref;
45322 }
45323 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
45324         LDKRetry* arg_conv = (LDKRetry*)arg;
45325         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
45326         return ret_conv;
45327 }
45328
45329 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
45330         LDKRetry* orig_conv = (LDKRetry*)orig;
45331         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45332         *ret_copy = Retry_clone(orig_conv);
45333         uint32_t ret_ref = (uintptr_t)ret_copy;
45334         return ret_ref;
45335 }
45336
45337 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
45338         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45339         *ret_copy = Retry_attempts(a);
45340         uint32_t ret_ref = (uintptr_t)ret_copy;
45341         return ret_ref;
45342 }
45343
45344 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
45345         LDKRetry* a_conv = (LDKRetry*)a;
45346         LDKRetry* b_conv = (LDKRetry*)b;
45347         jboolean ret_conv = Retry_eq(a_conv, b_conv);
45348         return ret_conv;
45349 }
45350
45351 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
45352         LDKRetry* o_conv = (LDKRetry*)o;
45353         int64_t ret_conv = Retry_hash(o_conv);
45354         return ret_conv;
45355 }
45356
45357 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
45358         if ((this_ptr & 1) != 0) return;
45359         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45360         CHECK_ACCESS(this_ptr_ptr);
45361         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45362         FREE((void*)this_ptr);
45363         PaymentError_free(this_ptr_conv);
45364 }
45365
45366 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45367         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45368         *ret_copy = PaymentError_clone(arg);
45369 uint32_t ret_ref = (uintptr_t)ret_copy;
45370         return ret_ref;
45371 }
45372 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
45373         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45374         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
45375         return ret_conv;
45376 }
45377
45378 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
45379         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45380         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45381         *ret_copy = PaymentError_clone(orig_conv);
45382         uint32_t ret_ref = (uintptr_t)ret_copy;
45383         return ret_ref;
45384 }
45385
45386 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
45387         LDKStr a_conv = str_ref_to_owned_c(a);
45388         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45389         *ret_copy = PaymentError_invoice(a_conv);
45390         uint32_t ret_ref = (uintptr_t)ret_copy;
45391         return ret_ref;
45392 }
45393
45394 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
45395         LDKLightningError a_conv;
45396         a_conv.inner = (void*)(a & (~1));
45397         a_conv.is_owned = (a & 1) || (a == 0);
45398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45399         a_conv = LightningError_clone(&a_conv);
45400         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45401         *ret_copy = PaymentError_routing(a_conv);
45402         uint32_t ret_ref = (uintptr_t)ret_copy;
45403         return ret_ref;
45404 }
45405
45406 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
45407         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45408         CHECK_ACCESS(a_ptr);
45409         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45410         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45411         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45412         *ret_copy = PaymentError_sending(a_conv);
45413         uint32_t ret_ref = (uintptr_t)ret_copy;
45414         return ret_ref;
45415 }
45416
45417 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) {
45418         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45419         CHECK_ACCESS(payer_ptr);
45420         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45421         if (payer_conv.free == LDKPayer_JCalls_free) {
45422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45423                 LDKPayer_JCalls_cloned(&payer_conv);
45424         }
45425         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45426         CHECK_ACCESS(router_ptr);
45427         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45428         if (router_conv.free == LDKRouter_JCalls_free) {
45429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45430                 LDKRouter_JCalls_cloned(&router_conv);
45431         }
45432         LDKMultiThreadedLockableScore scorer_conv;
45433         scorer_conv.inner = (void*)(scorer & (~1));
45434         scorer_conv.is_owned = false;
45435         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45436         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45437         CHECK_ACCESS(logger_ptr);
45438         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45439         if (logger_conv.free == LDKLogger_JCalls_free) {
45440                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45441                 LDKLogger_JCalls_cloned(&logger_conv);
45442         }
45443         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45444         CHECK_ACCESS(event_handler_ptr);
45445         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45446         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45447                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45448                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45449         }
45450         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
45451         CHECK_ACCESS(retry_ptr);
45452         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
45453         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
45454         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
45455         uint32_t ret_ref = 0;
45456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45459         ret_ref = (uintptr_t)ret_var.inner;
45460         if (ret_var.is_owned) {
45461                 ret_ref |= 1;
45462         }
45463         return ret_ref;
45464 }
45465
45466 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
45467         LDKInvoicePayer this_arg_conv;
45468         this_arg_conv.inner = (void*)(this_arg & (~1));
45469         this_arg_conv.is_owned = false;
45470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45471         LDKInvoice invoice_conv;
45472         invoice_conv.inner = (void*)(invoice & (~1));
45473         invoice_conv.is_owned = false;
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45475         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45476         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45477         return (uint32_t)ret_conv;
45478 }
45479
45480 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) {
45481         LDKInvoicePayer this_arg_conv;
45482         this_arg_conv.inner = (void*)(this_arg & (~1));
45483         this_arg_conv.is_owned = false;
45484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45485         LDKInvoice invoice_conv;
45486         invoice_conv.inner = (void*)(invoice & (~1));
45487         invoice_conv.is_owned = false;
45488         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45489         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45490         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45491         return (uint32_t)ret_conv;
45492 }
45493
45494 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) {
45495         LDKInvoicePayer this_arg_conv;
45496         this_arg_conv.inner = (void*)(this_arg & (~1));
45497         this_arg_conv.is_owned = false;
45498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45499         LDKPublicKey pubkey_ref;
45500         CHECK(pubkey->arr_len == 33);
45501         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
45502         LDKThirtyTwoBytes payment_preimage_ref;
45503         CHECK(payment_preimage->arr_len == 32);
45504         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
45505         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45506         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45507         return (uint32_t)ret_conv;
45508 }
45509
45510 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
45511         LDKInvoicePayer this_arg_conv;
45512         this_arg_conv.inner = (void*)(this_arg & (~1));
45513         this_arg_conv.is_owned = false;
45514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45515         unsigned char payment_hash_arr[32];
45516         CHECK(payment_hash->arr_len == 32);
45517         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
45518         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45519         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45520 }
45521
45522 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
45523         LDKInvoicePayer this_arg_conv;
45524         this_arg_conv.inner = (void*)(this_arg & (~1));
45525         this_arg_conv.is_owned = false;
45526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45527         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45528         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45529         return (uint32_t)ret_ret;
45530 }
45531
45532 uint32_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, uint32_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
45533         LDKChannelManager channelmanager_conv;
45534         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45535         channelmanager_conv.is_owned = false;
45536         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45537         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45538         CHECK_ACCESS(keys_manager_ptr);
45539         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45540         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45542                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45543         }
45544         LDKCurrency network_conv = LDKCurrency_from_js(network);
45545         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45546         CHECK_ACCESS(amt_msat_ptr);
45547         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45548         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45549         LDKSha256 description_hash_conv;
45550         description_hash_conv.inner = (void*)(description_hash & (~1));
45551         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
45552         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
45553         description_hash_conv = Sha256_clone(&description_hash_conv);
45554         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45555         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
45556         return (uint32_t)ret_conv;
45557 }
45558
45559 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, int32_t invoice_expiry_delta_secs) {
45560         LDKChannelManager channelmanager_conv;
45561         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45562         channelmanager_conv.is_owned = false;
45563         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45564         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45565         CHECK_ACCESS(keys_manager_ptr);
45566         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45567         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45568                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45569                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45570         }
45571         LDKCurrency network_conv = LDKCurrency_from_js(network);
45572         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45573         CHECK_ACCESS(amt_msat_ptr);
45574         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45575         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45576         LDKStr description_conv = str_ref_to_owned_c(description);
45577         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45578         *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, invoice_expiry_delta_secs);
45579         return (uint32_t)ret_conv;
45580 }
45581
45582 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
45583         LDKDefaultRouter this_obj_conv;
45584         this_obj_conv.inner = (void*)(this_obj & (~1));
45585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45587         DefaultRouter_free(this_obj_conv);
45588 }
45589
45590 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
45591         LDKNetworkGraph network_graph_conv;
45592         network_graph_conv.inner = (void*)(network_graph & (~1));
45593         network_graph_conv.is_owned = false;
45594         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45595         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45596         CHECK_ACCESS(logger_ptr);
45597         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45598         if (logger_conv.free == LDKLogger_JCalls_free) {
45599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45600                 LDKLogger_JCalls_cloned(&logger_conv);
45601         }
45602         LDKThirtyTwoBytes random_seed_bytes_ref;
45603         CHECK(random_seed_bytes->arr_len == 32);
45604         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
45605         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
45606         uint32_t ret_ref = 0;
45607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45610         ret_ref = (uintptr_t)ret_var.inner;
45611         if (ret_var.is_owned) {
45612                 ret_ref |= 1;
45613         }
45614         return ret_ref;
45615 }
45616
45617 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
45618         LDKDefaultRouter this_arg_conv;
45619         this_arg_conv.inner = (void*)(this_arg & (~1));
45620         this_arg_conv.is_owned = false;
45621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45622         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45623         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45624         return (uint32_t)ret_ret;
45625 }
45626
45627 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
45628         LDKChannelManager this_arg_conv;
45629         this_arg_conv.inner = (void*)(this_arg & (~1));
45630         this_arg_conv.is_owned = false;
45631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45632         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45633         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45634         return (uint32_t)ret_ret;
45635 }
45636
45637 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
45638         LDKStr s_conv = str_ref_to_owned_c(s);
45639         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
45640         *ret_conv = SiPrefix_from_str(s_conv);
45641         return (uint32_t)ret_conv;
45642 }
45643
45644 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
45645         LDKStr s_conv = str_ref_to_owned_c(s);
45646         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
45647         *ret_conv = Invoice_from_str(s_conv);
45648         return (uint32_t)ret_conv;
45649 }
45650
45651 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
45652         LDKStr s_conv = str_ref_to_owned_c(s);
45653         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
45654         *ret_conv = SignedRawInvoice_from_str(s_conv);
45655         return (uint32_t)ret_conv;
45656 }
45657
45658 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
45659         LDKParseError* o_conv = (LDKParseError*)o;
45660         LDKStr ret_str = ParseError_to_str(o_conv);
45661         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45662         Str_free(ret_str);
45663         return ret_conv;
45664 }
45665
45666 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
45667         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
45668         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
45669         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45670         Str_free(ret_str);
45671         return ret_conv;
45672 }
45673
45674 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
45675         LDKInvoice o_conv;
45676         o_conv.inner = (void*)(o & (~1));
45677         o_conv.is_owned = false;
45678         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45679         LDKStr ret_str = Invoice_to_str(&o_conv);
45680         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45681         Str_free(ret_str);
45682         return ret_conv;
45683 }
45684
45685 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
45686         LDKSignedRawInvoice o_conv;
45687         o_conv.inner = (void*)(o & (~1));
45688         o_conv.is_owned = false;
45689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45690         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
45691         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45692         Str_free(ret_str);
45693         return ret_conv;
45694 }
45695
45696 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
45697         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
45698         LDKStr ret_str = Currency_to_str(o_conv);
45699         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45700         Str_free(ret_str);
45701         return ret_conv;
45702 }
45703
45704 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
45705         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
45706         LDKStr ret_str = SiPrefix_to_str(o_conv);
45707         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45708         Str_free(ret_str);
45709         return ret_conv;
45710 }
45711