[TS] Update auto-generated TS bindings
[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 struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1136 CHECK(owner->result_ok);
1137         return PaymentParameters_clone(&*owner->contents.result);
1138 }
1139 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1140         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1141         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1142         uint32_t ret_ref = 0;
1143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1146         ret_ref = (uintptr_t)ret_var.inner;
1147         if (ret_var.is_owned) {
1148                 ret_ref |= 1;
1149         }
1150         return ret_ref;
1151 }
1152
1153 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1154 CHECK(!owner->result_ok);
1155         return DecodeError_clone(&*owner->contents.err);
1156 }
1157 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1158         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1159         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1160         uint32_t ret_ref = 0;
1161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1164         ret_ref = (uintptr_t)ret_var.inner;
1165         if (ret_var.is_owned) {
1166                 ret_ref |= 1;
1167         }
1168         return ret_ref;
1169 }
1170
1171 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1172         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1173         for (size_t i = 0; i < ret.datalen; i++) {
1174                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1175         }
1176         return ret;
1177 }
1178 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1179 CHECK(owner->result_ok);
1180         return RouteHint_clone(&*owner->contents.result);
1181 }
1182 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1183         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1184         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1185         uint32_t ret_ref = 0;
1186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1189         ret_ref = (uintptr_t)ret_var.inner;
1190         if (ret_var.is_owned) {
1191                 ret_ref |= 1;
1192         }
1193         return ret_ref;
1194 }
1195
1196 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1197 CHECK(!owner->result_ok);
1198         return DecodeError_clone(&*owner->contents.err);
1199 }
1200 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1201         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1202         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1203         uint32_t ret_ref = 0;
1204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1207         ret_ref = (uintptr_t)ret_var.inner;
1208         if (ret_var.is_owned) {
1209                 ret_ref |= 1;
1210         }
1211         return ret_ref;
1212 }
1213
1214 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1215 CHECK(owner->result_ok);
1216         return RouteHintHop_clone(&*owner->contents.result);
1217 }
1218 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1219         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1220         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1221         uint32_t ret_ref = 0;
1222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1225         ret_ref = (uintptr_t)ret_var.inner;
1226         if (ret_var.is_owned) {
1227                 ret_ref |= 1;
1228         }
1229         return ret_ref;
1230 }
1231
1232 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1233 CHECK(!owner->result_ok);
1234         return DecodeError_clone(&*owner->contents.err);
1235 }
1236 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1237         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1238         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1239         uint32_t ret_ref = 0;
1240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1243         ret_ref = (uintptr_t)ret_var.inner;
1244         if (ret_var.is_owned) {
1245                 ret_ref |= 1;
1246         }
1247         return ret_ref;
1248 }
1249
1250 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1251         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1252         for (size_t i = 0; i < ret.datalen; i++) {
1253                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1254         }
1255         return ret;
1256 }
1257 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1258 CHECK(owner->result_ok);
1259         return Route_clone(&*owner->contents.result);
1260 }
1261 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1262         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1263         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1264         uint32_t ret_ref = 0;
1265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1268         ret_ref = (uintptr_t)ret_var.inner;
1269         if (ret_var.is_owned) {
1270                 ret_ref |= 1;
1271         }
1272         return ret_ref;
1273 }
1274
1275 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1276 CHECK(!owner->result_ok);
1277         return LightningError_clone(&*owner->contents.err);
1278 }
1279 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1280         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1281         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1282         uint32_t ret_ref = 0;
1283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1286         ret_ref = (uintptr_t)ret_var.inner;
1287         if (ret_var.is_owned) {
1288                 ret_ref |= 1;
1289         }
1290         return ret_ref;
1291 }
1292
1293 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1294         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1295         switch(obj->tag) {
1296                 case LDKPaymentPurpose_InvoicePayment: return 0;
1297                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1298                 default: abort();
1299         }
1300 }
1301 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1302         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1303         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1304                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1305                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1306         return payment_preimage_arr;
1307 }
1308 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1309         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1310         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1311                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1312                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1313         return payment_secret_arr;
1314 }
1315 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1316         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1317         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1318                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1319                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1320         return spontaneous_payment_arr;
1321 }
1322 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1323 CHECK(owner->result_ok);
1324         return PaymentPurpose_clone(&*owner->contents.result);
1325 }
1326 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1327         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1328         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1329         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1330         uint32_t ret_ref = (uintptr_t)ret_copy;
1331         return ret_ref;
1332 }
1333
1334 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1335 CHECK(!owner->result_ok);
1336         return DecodeError_clone(&*owner->contents.err);
1337 }
1338 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1339         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1340         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1341         uint32_t ret_ref = 0;
1342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1345         ret_ref = (uintptr_t)ret_var.inner;
1346         if (ret_var.is_owned) {
1347                 ret_ref |= 1;
1348         }
1349         return ret_ref;
1350 }
1351
1352 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1353         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1354         switch(obj->tag) {
1355                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1356                 case LDKClosureReason_HolderForceClosed: return 1;
1357                 case LDKClosureReason_CooperativeClosure: return 2;
1358                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1359                 case LDKClosureReason_FundingTimedOut: return 4;
1360                 case LDKClosureReason_ProcessingError: return 5;
1361                 case LDKClosureReason_DisconnectedPeer: return 6;
1362                 case LDKClosureReason_OutdatedChannelManager: return 7;
1363                 default: abort();
1364         }
1365 }
1366 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1367         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1368         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1369                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1370                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1371         return peer_msg_conv;
1372 }
1373 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1374         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1375         assert(obj->tag == LDKClosureReason_ProcessingError);
1376                         LDKStr err_str = obj->processing_error.err;
1377                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1378         return err_conv;
1379 }
1380 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1381         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1382         switch(obj->tag) {
1383                 case LDKCOption_ClosureReasonZ_Some: return 0;
1384                 case LDKCOption_ClosureReasonZ_None: return 1;
1385                 default: abort();
1386         }
1387 }
1388 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1389         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1390         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1391                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1392         return some_ref;
1393 }
1394 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1395 CHECK(owner->result_ok);
1396         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1397 }
1398 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1399         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1400         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1401         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1402         uint32_t ret_ref = (uintptr_t)ret_copy;
1403         return ret_ref;
1404 }
1405
1406 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1407 CHECK(!owner->result_ok);
1408         return DecodeError_clone(&*owner->contents.err);
1409 }
1410 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1411         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1412         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1413         uint32_t ret_ref = 0;
1414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1417         ret_ref = (uintptr_t)ret_var.inner;
1418         if (ret_var.is_owned) {
1419                 ret_ref |= 1;
1420         }
1421         return ret_ref;
1422 }
1423
1424 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1425         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1426         switch(obj->tag) {
1427                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1428                 case LDKNetworkUpdate_ChannelFailure: return 1;
1429                 case LDKNetworkUpdate_NodeFailure: return 2;
1430                 default: abort();
1431         }
1432 }
1433 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1434         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1435         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1436                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1437                         uint32_t msg_ref = 0;
1438                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1439                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1440                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1441                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1442         return msg_ref;
1443 }
1444 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1445         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1446         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1447                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1448         return short_channel_id_conv;
1449 }
1450 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1451         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1452         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1453                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1454         return is_permanent_conv;
1455 }
1456 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1457         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1458         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1459                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1460                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1461         return node_id_arr;
1462 }
1463 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1464         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1465         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1466                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1467         return is_permanent_conv;
1468 }
1469 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1470         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1471         switch(obj->tag) {
1472                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1473                 case LDKCOption_NetworkUpdateZ_None: return 1;
1474                 default: abort();
1475         }
1476 }
1477 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1478         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1479         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1480                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1481         return some_ref;
1482 }
1483 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1484         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1485         switch(obj->tag) {
1486                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1487                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1488                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1489                 default: abort();
1490         }
1491 }
1492 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1493         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1494         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1495                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1496                         uint32_t outpoint_ref = 0;
1497                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1498                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1499                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1500                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1501         return outpoint_ref;
1502 }
1503 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1504         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1505         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1506                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1507         return (uint32_t)output_ref;
1508 }
1509 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1510         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1511         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1512                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1513                         uint32_t delayed_payment_output_ref = 0;
1514                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1515                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1516                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1517                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1518         return delayed_payment_output_ref;
1519 }
1520 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1521         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1522         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1523                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1524                         uint32_t static_payment_output_ref = 0;
1525                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1526                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1527                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1528                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1529         return static_payment_output_ref;
1530 }
1531 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1532         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1533         for (size_t i = 0; i < ret.datalen; i++) {
1534                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1535         }
1536         return ret;
1537 }
1538 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1539         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1540         switch(obj->tag) {
1541                 case LDKEvent_FundingGenerationReady: return 0;
1542                 case LDKEvent_PaymentReceived: return 1;
1543                 case LDKEvent_PaymentClaimed: return 2;
1544                 case LDKEvent_PaymentSent: return 3;
1545                 case LDKEvent_PaymentFailed: return 4;
1546                 case LDKEvent_PaymentPathSuccessful: return 5;
1547                 case LDKEvent_PaymentPathFailed: return 6;
1548                 case LDKEvent_PendingHTLCsForwardable: return 7;
1549                 case LDKEvent_SpendableOutputs: return 8;
1550                 case LDKEvent_PaymentForwarded: return 9;
1551                 case LDKEvent_ChannelClosed: return 10;
1552                 case LDKEvent_DiscardFunding: return 11;
1553                 case LDKEvent_OpenChannelRequest: return 12;
1554                 default: abort();
1555         }
1556 }
1557 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1558         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1559         assert(obj->tag == LDKEvent_FundingGenerationReady);
1560                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1561                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1562         return temporary_channel_id_arr;
1563 }
1564 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1565         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1566         assert(obj->tag == LDKEvent_FundingGenerationReady);
1567                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1568                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1569         return counterparty_node_id_arr;
1570 }
1571 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1572         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1573         assert(obj->tag == LDKEvent_FundingGenerationReady);
1574                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1575         return channel_value_satoshis_conv;
1576 }
1577 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1578         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1579         assert(obj->tag == LDKEvent_FundingGenerationReady);
1580                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1581                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1582                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1583         return output_script_arr;
1584 }
1585 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1586         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1587         assert(obj->tag == LDKEvent_FundingGenerationReady);
1588                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1589         return user_channel_id_conv;
1590 }
1591 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1592         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1593         assert(obj->tag == LDKEvent_PaymentReceived);
1594                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1595                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1596         return payment_hash_arr;
1597 }
1598 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1599         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1600         assert(obj->tag == LDKEvent_PaymentReceived);
1601                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1602         return amount_msat_conv;
1603 }
1604 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1605         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1606         assert(obj->tag == LDKEvent_PaymentReceived);
1607                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1608         return purpose_ref;
1609 }
1610 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1611         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1612         assert(obj->tag == LDKEvent_PaymentClaimed);
1613                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1614                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1615         return payment_hash_arr;
1616 }
1617 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1618         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1619         assert(obj->tag == LDKEvent_PaymentClaimed);
1620                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1621         return amount_msat_conv;
1622 }
1623 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1624         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1625         assert(obj->tag == LDKEvent_PaymentClaimed);
1626                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1627         return purpose_ref;
1628 }
1629 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1630         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1631         assert(obj->tag == LDKEvent_PaymentSent);
1632                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1633                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1634         return payment_id_arr;
1635 }
1636 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1637         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1638         assert(obj->tag == LDKEvent_PaymentSent);
1639                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1640                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1641         return payment_preimage_arr;
1642 }
1643 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1644         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1645         assert(obj->tag == LDKEvent_PaymentSent);
1646                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1647                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1648         return payment_hash_arr;
1649 }
1650 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1651         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1652         assert(obj->tag == LDKEvent_PaymentSent);
1653                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1654         return fee_paid_msat_ref;
1655 }
1656 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1657         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1658         assert(obj->tag == LDKEvent_PaymentFailed);
1659                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1660                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1661         return payment_id_arr;
1662 }
1663 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1664         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1665         assert(obj->tag == LDKEvent_PaymentFailed);
1666                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1667                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1668         return payment_hash_arr;
1669 }
1670 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1671         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1672         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1673                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1674                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1675         return payment_id_arr;
1676 }
1677 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1678         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1679         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1680                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1681                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1682         return payment_hash_arr;
1683 }
1684 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1685         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1686         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1687                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1688                         uint32_tArray path_arr = NULL;
1689                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1690                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1691                         for (size_t k = 0; k < path_var.datalen; k++) {
1692                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1693                                 uint32_t path_conv_10_ref = 0;
1694                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1697                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1698                                 path_arr_ptr[k] = path_conv_10_ref;
1699                         }
1700                         
1701         return path_arr;
1702 }
1703 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1704         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1705         assert(obj->tag == LDKEvent_PaymentPathFailed);
1706                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1707                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1708         return payment_id_arr;
1709 }
1710 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1711         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1712         assert(obj->tag == LDKEvent_PaymentPathFailed);
1713                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1714                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1715         return payment_hash_arr;
1716 }
1717 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1718         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1719         assert(obj->tag == LDKEvent_PaymentPathFailed);
1720                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1721         return rejected_by_dest_conv;
1722 }
1723 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1724         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1725         assert(obj->tag == LDKEvent_PaymentPathFailed);
1726                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1727         return network_update_ref;
1728 }
1729 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1730         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1731         assert(obj->tag == LDKEvent_PaymentPathFailed);
1732                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1733         return all_paths_failed_conv;
1734 }
1735 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1736         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1737         assert(obj->tag == LDKEvent_PaymentPathFailed);
1738                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1739                         uint32_tArray path_arr = NULL;
1740                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1741                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1742                         for (size_t k = 0; k < path_var.datalen; k++) {
1743                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1744                                 uint32_t path_conv_10_ref = 0;
1745                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1746                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1747                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1748                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1749                                 path_arr_ptr[k] = path_conv_10_ref;
1750                         }
1751                         
1752         return path_arr;
1753 }
1754 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1755         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1756         assert(obj->tag == LDKEvent_PaymentPathFailed);
1757                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1758         return short_channel_id_ref;
1759 }
1760 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1761         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1762         assert(obj->tag == LDKEvent_PaymentPathFailed);
1763                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1764                         uint32_t retry_ref = 0;
1765                         if ((uintptr_t)retry_var.inner > 4096) {
1766                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1767                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1768                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1769                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1770                         }
1771         return retry_ref;
1772 }
1773 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1774         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1775         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1776                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1777         return time_forwardable_conv;
1778 }
1779 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1780         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1781         assert(obj->tag == LDKEvent_SpendableOutputs);
1782                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1783                         uint32_tArray outputs_arr = NULL;
1784                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1785                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1786                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1787                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1788                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1789                         }
1790                         
1791         return outputs_arr;
1792 }
1793 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1794         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1795         assert(obj->tag == LDKEvent_PaymentForwarded);
1796                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1797                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1798         return prev_channel_id_arr;
1799 }
1800 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1801         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1802         assert(obj->tag == LDKEvent_PaymentForwarded);
1803                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1804                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1805         return next_channel_id_arr;
1806 }
1807 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1808         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1809         assert(obj->tag == LDKEvent_PaymentForwarded);
1810                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1811         return fee_earned_msat_ref;
1812 }
1813 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1814         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1815         assert(obj->tag == LDKEvent_PaymentForwarded);
1816                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1817         return claim_from_onchain_tx_conv;
1818 }
1819 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1820         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1821         assert(obj->tag == LDKEvent_ChannelClosed);
1822                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1823                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1824         return channel_id_arr;
1825 }
1826 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1827         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1828         assert(obj->tag == LDKEvent_ChannelClosed);
1829                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1830         return user_channel_id_conv;
1831 }
1832 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1833         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1834         assert(obj->tag == LDKEvent_ChannelClosed);
1835                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1836         return reason_ref;
1837 }
1838 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1839         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1840         assert(obj->tag == LDKEvent_DiscardFunding);
1841                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1842                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1843         return channel_id_arr;
1844 }
1845 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1846         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1847         assert(obj->tag == LDKEvent_DiscardFunding);
1848                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1849                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1850                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1851         return transaction_arr;
1852 }
1853 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1854         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1855         assert(obj->tag == LDKEvent_OpenChannelRequest);
1856                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1857                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1858         return temporary_channel_id_arr;
1859 }
1860 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1861         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1862         assert(obj->tag == LDKEvent_OpenChannelRequest);
1863                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1864                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1865         return counterparty_node_id_arr;
1866 }
1867 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1868         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1869         assert(obj->tag == LDKEvent_OpenChannelRequest);
1870                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
1871         return funding_satoshis_conv;
1872 }
1873 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1874         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1875         assert(obj->tag == LDKEvent_OpenChannelRequest);
1876                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
1877         return push_msat_conv;
1878 }
1879 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1880         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1881         assert(obj->tag == LDKEvent_OpenChannelRequest);
1882                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1883                         uint32_t channel_type_ref = 0;
1884                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1885                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1886                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1887                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1888         return channel_type_ref;
1889 }
1890 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1891         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1892         switch(obj->tag) {
1893                 case LDKCOption_EventZ_Some: return 0;
1894                 case LDKCOption_EventZ_None: return 1;
1895                 default: abort();
1896         }
1897 }
1898 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1899         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1900         assert(obj->tag == LDKCOption_EventZ_Some);
1901                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1902         return some_ref;
1903 }
1904 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1905 CHECK(owner->result_ok);
1906         return COption_EventZ_clone(&*owner->contents.result);
1907 }
1908 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1909         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1910         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1911         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1912         uint32_t ret_ref = (uintptr_t)ret_copy;
1913         return ret_ref;
1914 }
1915
1916 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1917 CHECK(!owner->result_ok);
1918         return DecodeError_clone(&*owner->contents.err);
1919 }
1920 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1921         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1922         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1923         uint32_t ret_ref = 0;
1924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1927         ret_ref = (uintptr_t)ret_var.inner;
1928         if (ret_var.is_owned) {
1929                 ret_ref |= 1;
1930         }
1931         return ret_ref;
1932 }
1933
1934 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1935         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1936         switch(obj->tag) {
1937                 case LDKErrorAction_DisconnectPeer: return 0;
1938                 case LDKErrorAction_IgnoreError: return 1;
1939                 case LDKErrorAction_IgnoreAndLog: return 2;
1940                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1941                 case LDKErrorAction_SendErrorMessage: return 4;
1942                 case LDKErrorAction_SendWarningMessage: return 5;
1943                 default: abort();
1944         }
1945 }
1946 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1947         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1948         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1949                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1950                         uint32_t msg_ref = 0;
1951                         if ((uintptr_t)msg_var.inner > 4096) {
1952                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1953                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1954                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1955                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1956                         }
1957         return msg_ref;
1958 }
1959 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1960         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1961         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1962                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1963         return ignore_and_log_conv;
1964 }
1965 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1966         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1967         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1968                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1969                         uint32_t msg_ref = 0;
1970                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1971                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1972                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1973                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1974         return msg_ref;
1975 }
1976 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1977         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1978         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1979                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1980                         uint32_t msg_ref = 0;
1981                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1982                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1983                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1984                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1985         return msg_ref;
1986 }
1987 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
1988         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1989         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1990                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
1991         return log_level_conv;
1992 }
1993 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
1994         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1995         switch(obj->tag) {
1996                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
1997                 case LDKMessageSendEvent_SendOpenChannel: return 1;
1998                 case LDKMessageSendEvent_SendFundingCreated: return 2;
1999                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2000                 case LDKMessageSendEvent_SendChannelReady: return 4;
2001                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2002                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2003                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2004                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2005                 case LDKMessageSendEvent_SendShutdown: return 9;
2006                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2007                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2008                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2009                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2010                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2011                 case LDKMessageSendEvent_HandleError: return 15;
2012                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2013                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2014                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2015                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2016                 default: abort();
2017         }
2018 }
2019 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2020         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2021         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2022                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2023                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2024         return node_id_arr;
2025 }
2026 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2027         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2028         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2029                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2030                         uint32_t msg_ref = 0;
2031                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2032                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2034                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2035         return msg_ref;
2036 }
2037 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2038         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2039         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2040                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2041                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2042         return node_id_arr;
2043 }
2044 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2045         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2046         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2047                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2048                         uint32_t msg_ref = 0;
2049                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2050                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2051                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2052                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2053         return msg_ref;
2054 }
2055 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2056         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2057         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2058                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2059                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2060         return node_id_arr;
2061 }
2062 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2063         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2064         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2065                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2066                         uint32_t msg_ref = 0;
2067                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2068                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2070                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2071         return msg_ref;
2072 }
2073 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2074         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2075         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2076                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2077                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2078         return node_id_arr;
2079 }
2080 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2081         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2082         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2083                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2084                         uint32_t msg_ref = 0;
2085                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2086                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2087                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2088                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2089         return msg_ref;
2090 }
2091 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2092         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2093         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2094                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2095                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2096         return node_id_arr;
2097 }
2098 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2099         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2100         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2101                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2102                         uint32_t msg_ref = 0;
2103                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2104                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2105                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2106                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2107         return msg_ref;
2108 }
2109 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2110         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2111         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2112                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2113                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2114         return node_id_arr;
2115 }
2116 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2117         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2118         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2119                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2120                         uint32_t msg_ref = 0;
2121                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2122                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2124                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2125         return msg_ref;
2126 }
2127 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2128         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2129         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2130                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2131                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2132         return node_id_arr;
2133 }
2134 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2135         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2136         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2137                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2138                         uint32_t updates_ref = 0;
2139                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2140                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2141                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2142                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2143         return updates_ref;
2144 }
2145 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2146         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2147         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2148                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2149                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2150         return node_id_arr;
2151 }
2152 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2153         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2154         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2155                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2156                         uint32_t msg_ref = 0;
2157                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2158                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2159                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2160                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2161         return msg_ref;
2162 }
2163 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2164         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2165         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2166                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2167                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2168         return node_id_arr;
2169 }
2170 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2172         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2173                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2174                         uint32_t msg_ref = 0;
2175                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2176                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2178                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2179         return msg_ref;
2180 }
2181 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2182         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2183         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2184                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2185                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2186         return node_id_arr;
2187 }
2188 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2190         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2191                         LDKShutdown msg_var = obj->send_shutdown.msg;
2192                         uint32_t msg_ref = 0;
2193                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2194                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2195                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2196                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2197         return msg_ref;
2198 }
2199 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2202                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2203                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2204         return node_id_arr;
2205 }
2206 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2208         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2209                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2210                         uint32_t msg_ref = 0;
2211                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2212                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2213                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2214                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2215         return msg_ref;
2216 }
2217 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2220                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.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 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2229         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2230         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2231                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2232                         uint32_t update_msg_ref = 0;
2233                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2234                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2235                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2236                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2237         return update_msg_ref;
2238 }
2239 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2240         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2241         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2242                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2243                         uint32_t msg_ref = 0;
2244                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2245                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2246                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2247                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2248         return msg_ref;
2249 }
2250 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2251         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2252         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2253                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2254                         uint32_t msg_ref = 0;
2255                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2256                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2257                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2258                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2259         return msg_ref;
2260 }
2261 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2262         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2263         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2264                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2265                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2266         return node_id_arr;
2267 }
2268 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2269         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2270         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2271                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2272                         uint32_t msg_ref = 0;
2273                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2274                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2275                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2276                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2277         return msg_ref;
2278 }
2279 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2280         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2281         assert(obj->tag == LDKMessageSendEvent_HandleError);
2282                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2283                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2284         return node_id_arr;
2285 }
2286 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2287         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2288         assert(obj->tag == LDKMessageSendEvent_HandleError);
2289                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2290         return action_ref;
2291 }
2292 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2293         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2294         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2295                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2296                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2297         return node_id_arr;
2298 }
2299 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2300         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2301         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2302                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2303                         uint32_t msg_ref = 0;
2304                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2305                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2306                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2307                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2308         return msg_ref;
2309 }
2310 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2311         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2312         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2313                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2314                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2315         return node_id_arr;
2316 }
2317 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2318         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2319         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2320                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2321                         uint32_t msg_ref = 0;
2322                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2323                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2324                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2325                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2326         return msg_ref;
2327 }
2328 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2329         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2330         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2331                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2332                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2333         return node_id_arr;
2334 }
2335 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2336         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2337         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2338                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2339                         uint32_t msg_ref = 0;
2340                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2341                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2342                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2343                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2344         return msg_ref;
2345 }
2346 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2347         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2348         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2349                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2350                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2351         return node_id_arr;
2352 }
2353 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2354         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2355         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2356                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2357                         uint32_t msg_ref = 0;
2358                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2359                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2360                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2361                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2362         return msg_ref;
2363 }
2364 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2365         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2366         for (size_t i = 0; i < ret.datalen; i++) {
2367                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2368         }
2369         return ret;
2370 }
2371 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2372 CHECK(owner->result_ok);
2373         return TxOut_clone(&*owner->contents.result);
2374 }
2375 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2376         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2377         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2378         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2379         return (uint32_t)ret_ref;
2380 }
2381
2382 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2383 CHECK(!owner->result_ok);
2384         return AccessError_clone(&*owner->contents.err);
2385 }
2386 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2387         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2388         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2389         return ret_conv;
2390 }
2391
2392 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2393         return owner->a;
2394 }
2395 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2396         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2397         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2398         return ret_conv;
2399 }
2400
2401 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2402         return owner->b;
2403 }
2404 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2405         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2406         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2409         return ret_arr;
2410 }
2411
2412 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2413         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2414         for (size_t i = 0; i < ret.datalen; i++) {
2415                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2416         }
2417         return ret;
2418 }
2419 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2420         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2421         for (size_t i = 0; i < ret.datalen; i++) {
2422                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2423         }
2424         return ret;
2425 }
2426 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2427 CHECK(owner->result_ok);
2428         return *owner->contents.result;
2429 }
2430 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2431         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2432         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2433 }
2434
2435 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2436 CHECK(!owner->result_ok);
2437         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2438 }
2439 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2440         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2441         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2442         return ret_conv;
2443 }
2444
2445 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2446         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2447         switch(obj->tag) {
2448                 case LDKMonitorEvent_HTLCEvent: return 0;
2449                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2450                 case LDKMonitorEvent_UpdateCompleted: return 2;
2451                 case LDKMonitorEvent_UpdateFailed: return 3;
2452                 default: abort();
2453         }
2454 }
2455 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2456         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2457         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2458                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2459                         uint32_t htlc_event_ref = 0;
2460                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2461                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2462                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2463                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2464         return htlc_event_ref;
2465 }
2466 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2467         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2468         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2469                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2470                         uint32_t commitment_tx_confirmed_ref = 0;
2471                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2472                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2473                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2474                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2475         return commitment_tx_confirmed_ref;
2476 }
2477 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2478         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2479         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2480                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2481                         uint32_t funding_txo_ref = 0;
2482                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2483                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2484                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2485                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2486         return funding_txo_ref;
2487 }
2488 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2489         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2490         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2491                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2492         return monitor_update_id_conv;
2493 }
2494 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2495         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2496         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2497                         LDKOutPoint update_failed_var = obj->update_failed;
2498                         uint32_t update_failed_ref = 0;
2499                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2500                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2502                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2503         return update_failed_ref;
2504 }
2505 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2506         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2507         for (size_t i = 0; i < ret.datalen; i++) {
2508                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2509         }
2510         return ret;
2511 }
2512 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2513         return OutPoint_clone(&owner->a);
2514 }
2515 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a(uint32_t owner) {
2516         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2517         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
2518         uint32_t ret_ref = 0;
2519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2522         ret_ref = (uintptr_t)ret_var.inner;
2523         if (ret_var.is_owned) {
2524                 ret_ref |= 1;
2525         }
2526         return ret_ref;
2527 }
2528
2529 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2530         return CVec_MonitorEventZ_clone(&owner->b);
2531 }
2532 uint32_tArray  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b(uint32_t owner) {
2533         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2534         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
2535         uint32_tArray ret_arr = NULL;
2536         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2537         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
2538         for (size_t o = 0; o < ret_var.datalen; o++) {
2539                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2540                 *ret_conv_14_copy = ret_var.data[o];
2541                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2542                 ret_arr_ptr[o] = ret_conv_14_ref;
2543         }
2544         
2545         FREE(ret_var.data);
2546         return ret_arr;
2547 }
2548
2549 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
2550         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
2551         for (size_t i = 0; i < ret.datalen; i++) {
2552                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
2553         }
2554         return ret;
2555 }
2556 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2557         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2558         switch(obj->tag) {
2559                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2560                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2561                 default: abort();
2562         }
2563 }
2564 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2565         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2566         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2567                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2568                         *some_conv = obj->some;
2569                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2570         return ((uint32_t)some_conv);
2571 }
2572 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2573 CHECK(owner->result_ok);
2574         return FixedPenaltyScorer_clone(&*owner->contents.result);
2575 }
2576 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2577         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2578         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2579         uint32_t ret_ref = 0;
2580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2583         ret_ref = (uintptr_t)ret_var.inner;
2584         if (ret_var.is_owned) {
2585                 ret_ref |= 1;
2586         }
2587         return ret_ref;
2588 }
2589
2590 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2591 CHECK(!owner->result_ok);
2592         return DecodeError_clone(&*owner->contents.err);
2593 }
2594 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2595         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2596         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2597         uint32_t ret_ref = 0;
2598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2601         ret_ref = (uintptr_t)ret_var.inner;
2602         if (ret_var.is_owned) {
2603                 ret_ref |= 1;
2604         }
2605         return ret_ref;
2606 }
2607
2608 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2609         return owner->a;
2610 }
2611 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint32_t owner) {
2612         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2613         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2614         return ret_conv;
2615 }
2616
2617 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2618         return owner->b;
2619 }
2620 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint32_t owner) {
2621         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2622         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2623         return ret_conv;
2624 }
2625
2626 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint32_t ptr) {
2627         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2628         switch(obj->tag) {
2629                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2630                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2631                 default: abort();
2632         }
2633 }
2634 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint32_t ptr) {
2635         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2636         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2637                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2638                         *some_conv = obj->some;
2639                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2640         return ((uint32_t)some_conv);
2641 }
2642 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2643         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2644         for (size_t i = 0; i < ret.datalen; i++) {
2645                 ret.data[i] = NodeId_clone(&orig->data[i]);
2646         }
2647         return ret;
2648 }
2649 typedef struct LDKLogger_JCalls {
2650         atomic_size_t refcnt;
2651         uint32_t instance_ptr;
2652 } LDKLogger_JCalls;
2653 static void LDKLogger_JCalls_free(void* this_arg) {
2654         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2655         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2656                 FREE(j_calls);
2657         }
2658 }
2659 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2660         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2661         LDKRecord record_var = *record;
2662         uint32_t record_ref = 0;
2663         record_var = Record_clone(&record_var);
2664         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2665         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2666         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2667         record_ref = (uintptr_t)record_var.inner;
2668         if (record_var.is_owned) {
2669                 record_ref |= 1;
2670         }
2671         js_invoke_function_u_u(j_calls->instance_ptr, 0, (uint32_t)record_ref);
2672 }
2673 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2674         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2675         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2676 }
2677 static inline LDKLogger LDKLogger_init (JSValue o) {
2678         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2679         atomic_init(&calls->refcnt, 1);
2680         calls->instance_ptr = o;
2681
2682         LDKLogger ret = {
2683                 .this_arg = (void*) calls,
2684                 .log = log_LDKLogger_jcall,
2685                 .free = LDKLogger_JCalls_free,
2686         };
2687         return ret;
2688 }
2689 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2690         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2691         *res_ptr = LDKLogger_init(o);
2692         return (long)res_ptr;
2693 }
2694 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2695 CHECK(owner->result_ok);
2696         return &*owner->contents.result;
2697 }
2698 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2699         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2700         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2701         uint32_t ret_ref = 0;
2702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2705         ret_ref = (uintptr_t)ret_var.inner & ~1;
2706         return ret_ref;
2707 }
2708
2709 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2710 CHECK(!owner->result_ok);
2711         return DecodeError_clone(&*owner->contents.err);
2712 }
2713 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2714         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2715         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2716         uint32_t ret_ref = 0;
2717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2720         ret_ref = (uintptr_t)ret_var.inner;
2721         if (ret_var.is_owned) {
2722                 ret_ref |= 1;
2723         }
2724         return ret_ref;
2725 }
2726
2727 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2728 CHECK(owner->result_ok);
2729         return InitFeatures_clone(&*owner->contents.result);
2730 }
2731 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2732         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2733         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2734         uint32_t ret_ref = 0;
2735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2738         ret_ref = (uintptr_t)ret_var.inner;
2739         if (ret_var.is_owned) {
2740                 ret_ref |= 1;
2741         }
2742         return ret_ref;
2743 }
2744
2745 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2746 CHECK(!owner->result_ok);
2747         return DecodeError_clone(&*owner->contents.err);
2748 }
2749 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2750         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2751         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2752         uint32_t ret_ref = 0;
2753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2756         ret_ref = (uintptr_t)ret_var.inner;
2757         if (ret_var.is_owned) {
2758                 ret_ref |= 1;
2759         }
2760         return ret_ref;
2761 }
2762
2763 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2764 CHECK(owner->result_ok);
2765         return ChannelFeatures_clone(&*owner->contents.result);
2766 }
2767 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2768         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2769         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2770         uint32_t ret_ref = 0;
2771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2774         ret_ref = (uintptr_t)ret_var.inner;
2775         if (ret_var.is_owned) {
2776                 ret_ref |= 1;
2777         }
2778         return ret_ref;
2779 }
2780
2781 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2782 CHECK(!owner->result_ok);
2783         return DecodeError_clone(&*owner->contents.err);
2784 }
2785 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2786         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2787         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2788         uint32_t ret_ref = 0;
2789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2792         ret_ref = (uintptr_t)ret_var.inner;
2793         if (ret_var.is_owned) {
2794                 ret_ref |= 1;
2795         }
2796         return ret_ref;
2797 }
2798
2799 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2800 CHECK(owner->result_ok);
2801         return NodeFeatures_clone(&*owner->contents.result);
2802 }
2803 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2804         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2805         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2806         uint32_t ret_ref = 0;
2807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2810         ret_ref = (uintptr_t)ret_var.inner;
2811         if (ret_var.is_owned) {
2812                 ret_ref |= 1;
2813         }
2814         return ret_ref;
2815 }
2816
2817 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2818 CHECK(!owner->result_ok);
2819         return DecodeError_clone(&*owner->contents.err);
2820 }
2821 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2822         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2823         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2824         uint32_t ret_ref = 0;
2825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2828         ret_ref = (uintptr_t)ret_var.inner;
2829         if (ret_var.is_owned) {
2830                 ret_ref |= 1;
2831         }
2832         return ret_ref;
2833 }
2834
2835 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2836 CHECK(owner->result_ok);
2837         return InvoiceFeatures_clone(&*owner->contents.result);
2838 }
2839 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2840         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2841         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2842         uint32_t ret_ref = 0;
2843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2846         ret_ref = (uintptr_t)ret_var.inner;
2847         if (ret_var.is_owned) {
2848                 ret_ref |= 1;
2849         }
2850         return ret_ref;
2851 }
2852
2853 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2854 CHECK(!owner->result_ok);
2855         return DecodeError_clone(&*owner->contents.err);
2856 }
2857 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2858         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2859         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2860         uint32_t ret_ref = 0;
2861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2864         ret_ref = (uintptr_t)ret_var.inner;
2865         if (ret_var.is_owned) {
2866                 ret_ref |= 1;
2867         }
2868         return ret_ref;
2869 }
2870
2871 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2872 CHECK(owner->result_ok);
2873         return ChannelTypeFeatures_clone(&*owner->contents.result);
2874 }
2875 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2876         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2877         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2878         uint32_t ret_ref = 0;
2879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2882         ret_ref = (uintptr_t)ret_var.inner;
2883         if (ret_var.is_owned) {
2884                 ret_ref |= 1;
2885         }
2886         return ret_ref;
2887 }
2888
2889 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2890 CHECK(!owner->result_ok);
2891         return DecodeError_clone(&*owner->contents.err);
2892 }
2893 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2894         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2895         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2896         uint32_t ret_ref = 0;
2897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2900         ret_ref = (uintptr_t)ret_var.inner;
2901         if (ret_var.is_owned) {
2902                 ret_ref |= 1;
2903         }
2904         return ret_ref;
2905 }
2906
2907 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2908 CHECK(owner->result_ok);
2909         return NodeId_clone(&*owner->contents.result);
2910 }
2911 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
2912         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2913         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
2914         uint32_t ret_ref = 0;
2915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2918         ret_ref = (uintptr_t)ret_var.inner;
2919         if (ret_var.is_owned) {
2920                 ret_ref |= 1;
2921         }
2922         return ret_ref;
2923 }
2924
2925 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2926 CHECK(!owner->result_ok);
2927         return DecodeError_clone(&*owner->contents.err);
2928 }
2929 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
2930         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2931         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
2932         uint32_t ret_ref = 0;
2933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2936         ret_ref = (uintptr_t)ret_var.inner;
2937         if (ret_var.is_owned) {
2938                 ret_ref |= 1;
2939         }
2940         return ret_ref;
2941 }
2942
2943 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2944 CHECK(owner->result_ok);
2945         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
2946 }
2947 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
2948         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2949         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
2950         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
2951         uint32_t ret_ref = (uintptr_t)ret_copy;
2952         return ret_ref;
2953 }
2954
2955 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2956 CHECK(!owner->result_ok);
2957         return DecodeError_clone(&*owner->contents.err);
2958 }
2959 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
2960         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2961         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
2962         uint32_t ret_ref = 0;
2963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2966         ret_ref = (uintptr_t)ret_var.inner;
2967         if (ret_var.is_owned) {
2968                 ret_ref |= 1;
2969         }
2970         return ret_ref;
2971 }
2972
2973 typedef struct LDKAccess_JCalls {
2974         atomic_size_t refcnt;
2975         uint32_t instance_ptr;
2976 } LDKAccess_JCalls;
2977 static void LDKAccess_JCalls_free(void* this_arg) {
2978         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2979         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2980                 FREE(j_calls);
2981         }
2982 }
2983 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
2984         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2985         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
2986         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
2987         int64_t short_channel_id_conv = short_channel_id;
2988         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
2989         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2990         CHECK_ACCESS(ret_ptr);
2991         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
2992         FREE((void*)ret);
2993         return ret_conv;
2994 }
2995 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
2996         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
2997         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2998 }
2999 static inline LDKAccess LDKAccess_init (JSValue o) {
3000         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3001         atomic_init(&calls->refcnt, 1);
3002         calls->instance_ptr = o;
3003
3004         LDKAccess ret = {
3005                 .this_arg = (void*) calls,
3006                 .get_utxo = get_utxo_LDKAccess_jcall,
3007                 .free = LDKAccess_JCalls_free,
3008         };
3009         return ret;
3010 }
3011 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3012         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3013         *res_ptr = LDKAccess_init(o);
3014         return (long)res_ptr;
3015 }
3016 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) {
3017         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3018         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3019         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3020         unsigned char genesis_hash_arr[32];
3021         CHECK(genesis_hash->arr_len == 32);
3022         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3023         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3024         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3025         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3026         return (uint32_t)ret_conv;
3027 }
3028
3029 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3030         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3031         switch(obj->tag) {
3032                 case LDKCOption_AccessZ_Some: return 0;
3033                 case LDKCOption_AccessZ_None: return 1;
3034                 default: abort();
3035         }
3036 }
3037 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3038         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3039         assert(obj->tag == LDKCOption_AccessZ_Some);
3040                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3041                         *some_ret = obj->some;
3042                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3043                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3044                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3045                                 LDKAccess_JCalls_cloned(&(*some_ret));
3046                         }
3047         return (uint32_t)some_ret;
3048 }
3049 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3050 CHECK(owner->result_ok);
3051         return *owner->contents.result;
3052 }
3053 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3054         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3055         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3056         return ret_conv;
3057 }
3058
3059 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3060 CHECK(!owner->result_ok);
3061         return LightningError_clone(&*owner->contents.err);
3062 }
3063 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3064         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3065         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3066         uint32_t ret_ref = 0;
3067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3070         ret_ref = (uintptr_t)ret_var.inner;
3071         if (ret_var.is_owned) {
3072                 ret_ref |= 1;
3073         }
3074         return ret_ref;
3075 }
3076
3077 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3078         return ChannelAnnouncement_clone(&owner->a);
3079 }
3080 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3081         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3082         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3083         uint32_t ret_ref = 0;
3084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3087         ret_ref = (uintptr_t)ret_var.inner;
3088         if (ret_var.is_owned) {
3089                 ret_ref |= 1;
3090         }
3091         return ret_ref;
3092 }
3093
3094 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3095         return ChannelUpdate_clone(&owner->b);
3096 }
3097 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3098         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3099         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3100         uint32_t ret_ref = 0;
3101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3104         ret_ref = (uintptr_t)ret_var.inner;
3105         if (ret_var.is_owned) {
3106                 ret_ref |= 1;
3107         }
3108         return ret_ref;
3109 }
3110
3111 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3112         return ChannelUpdate_clone(&owner->c);
3113 }
3114 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3115         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3116         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3117         uint32_t ret_ref = 0;
3118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3121         ret_ref = (uintptr_t)ret_var.inner;
3122         if (ret_var.is_owned) {
3123                 ret_ref |= 1;
3124         }
3125         return ret_ref;
3126 }
3127
3128 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3129         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3130         for (size_t i = 0; i < ret.datalen; i++) {
3131                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3132         }
3133         return ret;
3134 }
3135 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3136         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3137         for (size_t i = 0; i < ret.datalen; i++) {
3138                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3139         }
3140         return ret;
3141 }
3142 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3143 CHECK(owner->result_ok);
3144         return *owner->contents.result;
3145 }
3146 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3147         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3148         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3149 }
3150
3151 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3152 CHECK(!owner->result_ok);
3153         return LightningError_clone(&*owner->contents.err);
3154 }
3155 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3156         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3157         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3158         uint32_t ret_ref = 0;
3159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3162         ret_ref = (uintptr_t)ret_var.inner;
3163         if (ret_var.is_owned) {
3164                 ret_ref |= 1;
3165         }
3166         return ret_ref;
3167 }
3168
3169 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3170 CHECK(owner->result_ok);
3171         return ChannelUpdateInfo_clone(&*owner->contents.result);
3172 }
3173 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3174         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3175         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3176         uint32_t ret_ref = 0;
3177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3180         ret_ref = (uintptr_t)ret_var.inner;
3181         if (ret_var.is_owned) {
3182                 ret_ref |= 1;
3183         }
3184         return ret_ref;
3185 }
3186
3187 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3188 CHECK(!owner->result_ok);
3189         return DecodeError_clone(&*owner->contents.err);
3190 }
3191 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3192         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3193         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3194         uint32_t ret_ref = 0;
3195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3198         ret_ref = (uintptr_t)ret_var.inner;
3199         if (ret_var.is_owned) {
3200                 ret_ref |= 1;
3201         }
3202         return ret_ref;
3203 }
3204
3205 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3206 CHECK(owner->result_ok);
3207         return ChannelInfo_clone(&*owner->contents.result);
3208 }
3209 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3210         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3211         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3212         uint32_t ret_ref = 0;
3213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3216         ret_ref = (uintptr_t)ret_var.inner;
3217         if (ret_var.is_owned) {
3218                 ret_ref |= 1;
3219         }
3220         return ret_ref;
3221 }
3222
3223 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3224 CHECK(!owner->result_ok);
3225         return DecodeError_clone(&*owner->contents.err);
3226 }
3227 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3228         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3229         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3230         uint32_t ret_ref = 0;
3231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3234         ret_ref = (uintptr_t)ret_var.inner;
3235         if (ret_var.is_owned) {
3236                 ret_ref |= 1;
3237         }
3238         return ret_ref;
3239 }
3240
3241 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3242 CHECK(owner->result_ok);
3243         return RoutingFees_clone(&*owner->contents.result);
3244 }
3245 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3246         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3247         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3248         uint32_t ret_ref = 0;
3249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3252         ret_ref = (uintptr_t)ret_var.inner;
3253         if (ret_var.is_owned) {
3254                 ret_ref |= 1;
3255         }
3256         return ret_ref;
3257 }
3258
3259 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3260 CHECK(!owner->result_ok);
3261         return DecodeError_clone(&*owner->contents.err);
3262 }
3263 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3264         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3265         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(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 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3278         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3279         switch(obj->tag) {
3280                 case LDKNetAddress_IPv4: return 0;
3281                 case LDKNetAddress_IPv6: return 1;
3282                 case LDKNetAddress_OnionV2: return 2;
3283                 case LDKNetAddress_OnionV3: return 3;
3284                 default: abort();
3285         }
3286 }
3287 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3288         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3289         assert(obj->tag == LDKNetAddress_IPv4);
3290                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3291                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3292         return addr_arr;
3293 }
3294 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3295         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3296         assert(obj->tag == LDKNetAddress_IPv4);
3297                         int16_t port_conv = obj->i_pv4.port;
3298         return port_conv;
3299 }
3300 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3301         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3302         assert(obj->tag == LDKNetAddress_IPv6);
3303                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3304                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3305         return addr_arr;
3306 }
3307 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3308         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3309         assert(obj->tag == LDKNetAddress_IPv6);
3310                         int16_t port_conv = obj->i_pv6.port;
3311         return port_conv;
3312 }
3313 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3314         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3315         assert(obj->tag == LDKNetAddress_OnionV2);
3316                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3317                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3318         return onion_v2_arr;
3319 }
3320 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3321         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3322         assert(obj->tag == LDKNetAddress_OnionV3);
3323                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3324                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3325         return ed25519_pubkey_arr;
3326 }
3327 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3328         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3329         assert(obj->tag == LDKNetAddress_OnionV3);
3330                         int16_t checksum_conv = obj->onion_v3.checksum;
3331         return checksum_conv;
3332 }
3333 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3334         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3335         assert(obj->tag == LDKNetAddress_OnionV3);
3336                         int8_t version_conv = obj->onion_v3.version;
3337         return version_conv;
3338 }
3339 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3340         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3341         assert(obj->tag == LDKNetAddress_OnionV3);
3342                         int16_t port_conv = obj->onion_v3.port;
3343         return port_conv;
3344 }
3345 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3346         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3347         for (size_t i = 0; i < ret.datalen; i++) {
3348                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3349         }
3350         return ret;
3351 }
3352 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(owner->result_ok);
3354         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3355 }
3356 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3357         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3358         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_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_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3371 CHECK(!owner->result_ok);
3372         return DecodeError_clone(&*owner->contents.err);
3373 }
3374 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3375         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3376         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_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 LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(owner->result_ok);
3390         return NodeAlias_clone(&*owner->contents.result);
3391 }
3392 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint32_t owner) {
3393         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3394         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_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_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3407 CHECK(!owner->result_ok);
3408         return DecodeError_clone(&*owner->contents.err);
3409 }
3410 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint32_t owner) {
3411         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3412         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_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 LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3425         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3426         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3427         return ret;
3428 }
3429 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3430 CHECK(owner->result_ok);
3431         return NodeInfo_clone(&*owner->contents.result);
3432 }
3433 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3434         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3435         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3436         uint32_t ret_ref = 0;
3437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3440         ret_ref = (uintptr_t)ret_var.inner;
3441         if (ret_var.is_owned) {
3442                 ret_ref |= 1;
3443         }
3444         return ret_ref;
3445 }
3446
3447 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3448 CHECK(!owner->result_ok);
3449         return DecodeError_clone(&*owner->contents.err);
3450 }
3451 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3452         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3453         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3454         uint32_t ret_ref = 0;
3455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3458         ret_ref = (uintptr_t)ret_var.inner;
3459         if (ret_var.is_owned) {
3460                 ret_ref |= 1;
3461         }
3462         return ret_ref;
3463 }
3464
3465 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3466 CHECK(owner->result_ok);
3467         return &*owner->contents.result;
3468 }
3469 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3470         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3471         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3472         uint32_t ret_ref = 0;
3473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3476         ret_ref = (uintptr_t)ret_var.inner & ~1;
3477         return ret_ref;
3478 }
3479
3480 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3481 CHECK(!owner->result_ok);
3482         return DecodeError_clone(&*owner->contents.err);
3483 }
3484 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3485         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3486         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3487         uint32_t ret_ref = 0;
3488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3491         ret_ref = (uintptr_t)ret_var.inner;
3492         if (ret_var.is_owned) {
3493                 ret_ref |= 1;
3494         }
3495         return ret_ref;
3496 }
3497
3498 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3499         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3500         switch(obj->tag) {
3501                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3502                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3503                 default: abort();
3504         }
3505 }
3506 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3507         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3508         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3509                         LDKCVec_NetAddressZ some_var = obj->some;
3510                         uint32_tArray some_arr = NULL;
3511                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3512                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
3513                         for (size_t m = 0; m < some_var.datalen; m++) {
3514                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3515                                 some_arr_ptr[m] = some_conv_12_ref;
3516                         }
3517                         
3518         return some_arr;
3519 }
3520 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3521 CHECK(owner->result_ok);
3522         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3523 }
3524 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3525         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3526         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3527         uint32_t ret_ref = 0;
3528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3531         ret_ref = (uintptr_t)ret_var.inner;
3532         if (ret_var.is_owned) {
3533                 ret_ref |= 1;
3534         }
3535         return ret_ref;
3536 }
3537
3538 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3539 CHECK(!owner->result_ok);
3540         return DecodeError_clone(&*owner->contents.err);
3541 }
3542 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3543         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3544         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3545         uint32_t ret_ref = 0;
3546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3549         ret_ref = (uintptr_t)ret_var.inner;
3550         if (ret_var.is_owned) {
3551                 ret_ref |= 1;
3552         }
3553         return ret_ref;
3554 }
3555
3556 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3557 CHECK(owner->result_ok);
3558         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3559 }
3560 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3561         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3562         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3563         uint32_t ret_ref = 0;
3564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3567         ret_ref = (uintptr_t)ret_var.inner;
3568         if (ret_var.is_owned) {
3569                 ret_ref |= 1;
3570         }
3571         return ret_ref;
3572 }
3573
3574 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3575 CHECK(!owner->result_ok);
3576         return DecodeError_clone(&*owner->contents.err);
3577 }
3578 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3579         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3580         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3581         uint32_t ret_ref = 0;
3582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3585         ret_ref = (uintptr_t)ret_var.inner;
3586         if (ret_var.is_owned) {
3587                 ret_ref |= 1;
3588         }
3589         return ret_ref;
3590 }
3591
3592 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3593 CHECK(owner->result_ok);
3594         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3595 }
3596 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3597         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3598         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3599         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3600         uint32_t ret_ref = (uintptr_t)ret_copy;
3601         return ret_ref;
3602 }
3603
3604 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3605 CHECK(!owner->result_ok);
3606         return DecodeError_clone(&*owner->contents.err);
3607 }
3608 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3609         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3610         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3611         uint32_t ret_ref = 0;
3612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3615         ret_ref = (uintptr_t)ret_var.inner;
3616         if (ret_var.is_owned) {
3617                 ret_ref |= 1;
3618         }
3619         return ret_ref;
3620 }
3621
3622 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3623         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3624         for (size_t i = 0; i < ret.datalen; i++) {
3625                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3626         }
3627         return ret;
3628 }
3629 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3630         return owner->a;
3631 }
3632 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3633         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3634         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3635         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3636         return ret_arr;
3637 }
3638
3639 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3640         return owner->b;
3641 }
3642 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3643         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3644         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3645         ptrArray ret_arr = NULL;
3646         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3647         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3648         for (size_t m = 0; m < ret_var.datalen; m++) {
3649                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3650                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3651                 ret_arr_ptr[m] = ret_conv_12_arr;
3652         }
3653         
3654         return ret_arr;
3655 }
3656
3657 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3658 CHECK(owner->result_ok);
3659         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3660 }
3661 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3662         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3663         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3664         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3665         return ((uint32_t)ret_conv);
3666 }
3667
3668 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3669 CHECK(!owner->result_ok);
3670         return *owner->contents.err;
3671 }
3672 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3673         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3674         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3675 }
3676
3677 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3678 CHECK(owner->result_ok);
3679         return *owner->contents.result;
3680 }
3681 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3682         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3683         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3684         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3685         return ret_arr;
3686 }
3687
3688 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3689 CHECK(!owner->result_ok);
3690         return *owner->contents.err;
3691 }
3692 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3693         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3694         CResult_SignatureNoneZ_get_err(owner_conv);
3695 }
3696
3697 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3698         return owner->a;
3699 }
3700 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3701         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3702         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3703         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3704         return ret_arr;
3705 }
3706
3707 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3708         return owner->b;
3709 }
3710 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3711         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3712         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3713         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3714         return ret_arr;
3715 }
3716
3717 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3718 CHECK(owner->result_ok);
3719         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3720 }
3721 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3722         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3723         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3724         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3725         return ((uint32_t)ret_conv);
3726 }
3727
3728 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3729 CHECK(!owner->result_ok);
3730         return *owner->contents.err;
3731 }
3732 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3733         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3734         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3735 }
3736
3737 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3738 CHECK(owner->result_ok);
3739         return *owner->contents.result;
3740 }
3741 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3742         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3743         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3744         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3745         return ret_arr;
3746 }
3747
3748 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3749 CHECK(!owner->result_ok);
3750         return *owner->contents.err;
3751 }
3752 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3753         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3754         CResult_SecretKeyNoneZ_get_err(owner_conv);
3755 }
3756
3757 typedef struct LDKBaseSign_JCalls {
3758         atomic_size_t refcnt;
3759         uint32_t instance_ptr;
3760 } LDKBaseSign_JCalls;
3761 static void LDKBaseSign_JCalls_free(void* this_arg) {
3762         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3763         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3764                 FREE(j_calls);
3765         }
3766 }
3767 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3768         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3769         int64_t idx_conv = idx;
3770         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 2, (uint32_t)idx_conv);
3771         LDKPublicKey ret_ref;
3772         CHECK(ret->arr_len == 33);
3773         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3774         return ret_ref;
3775 }
3776 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3777         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3778         int64_t idx_conv = idx;
3779         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 3, (uint32_t)idx_conv);
3780         LDKThirtyTwoBytes ret_ref;
3781         CHECK(ret->arr_len == 32);
3782         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3783         return ret_ref;
3784 }
3785 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3786         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3787         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3788         uint32_t holder_tx_ref = 0;
3789         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3790         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3791         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3792         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3793         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3794         if (holder_tx_var.is_owned) {
3795                 holder_tx_ref |= 1;
3796         }
3797         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3798         ptrArray preimages_arr = NULL;
3799         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3800         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3801         for (size_t m = 0; m < preimages_var.datalen; m++) {
3802                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3803                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3804                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3805         }
3806         
3807         FREE(preimages_var.data);
3808         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 4, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3809         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3810         CHECK_ACCESS(ret_ptr);
3811         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3812         FREE((void*)ret);
3813         return ret_conv;
3814 }
3815 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3816         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3817         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 5);
3818         LDKThirtyTwoBytes ret_ref;
3819         CHECK(ret->arr_len == 32);
3820         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3821         return ret_ref;
3822 }
3823 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3824         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3825         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3826         uint32_t commitment_tx_ref = 0;
3827         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3828         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3829         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3830         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3831         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3832         if (commitment_tx_var.is_owned) {
3833                 commitment_tx_ref |= 1;
3834         }
3835         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3836         ptrArray preimages_arr = NULL;
3837         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3838         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3839         for (size_t m = 0; m < preimages_var.datalen; m++) {
3840                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3841                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3842                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3843         }
3844         
3845         FREE(preimages_var.data);
3846         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3847         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3848         CHECK_ACCESS(ret_ptr);
3849         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3850         FREE((void*)ret);
3851         return ret_conv;
3852 }
3853 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3854         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3855         int64_t idx_conv = idx;
3856         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3857         memcpy(secret_arr->elems, *secret, 32);
3858         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr);
3859         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3860         CHECK_ACCESS(ret_ptr);
3861         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3862         FREE((void*)ret);
3863         return ret_conv;
3864 }
3865 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3866         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3867         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3868         uint32_t commitment_tx_ref = 0;
3869         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3870         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3871         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3872         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3873         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3874         if (commitment_tx_var.is_owned) {
3875                 commitment_tx_ref |= 1;
3876         }
3877         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref);
3878         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3879         CHECK_ACCESS(ret_ptr);
3880         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3881         FREE((void*)ret);
3882         return ret_conv;
3883 }
3884 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]) {
3885         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3886         LDKTransaction justice_tx_var = justice_tx;
3887         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3888         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3889         Transaction_free(justice_tx_var);
3890         uint32_t input_conv = input;
3891         int64_t amount_conv = amount;
3892         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3893         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3894         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);
3895         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3896         CHECK_ACCESS(ret_ptr);
3897         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3898         FREE((void*)ret);
3899         return ret_conv;
3900 }
3901 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) {
3902         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3903         LDKTransaction justice_tx_var = justice_tx;
3904         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3905         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3906         Transaction_free(justice_tx_var);
3907         uint32_t input_conv = input;
3908         int64_t amount_conv = amount;
3909         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3910         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3911         LDKHTLCOutputInCommitment htlc_var = *htlc;
3912         uint32_t htlc_ref = 0;
3913         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3914         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3915         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3916         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3917         htlc_ref = (uintptr_t)htlc_var.inner;
3918         if (htlc_var.is_owned) {
3919                 htlc_ref |= 1;
3920         }
3921         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);
3922         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3923         CHECK_ACCESS(ret_ptr);
3924         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3925         FREE((void*)ret);
3926         return ret_conv;
3927 }
3928 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) {
3929         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3930         LDKTransaction htlc_tx_var = htlc_tx;
3931         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3932         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3933         Transaction_free(htlc_tx_var);
3934         uint32_t input_conv = input;
3935         int64_t amount_conv = amount;
3936         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3937         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3938         LDKHTLCOutputInCommitment htlc_var = *htlc;
3939         uint32_t htlc_ref = 0;
3940         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3941         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3942         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3943         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3944         htlc_ref = (uintptr_t)htlc_var.inner;
3945         if (htlc_var.is_owned) {
3946                 htlc_ref |= 1;
3947         }
3948         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);
3949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3950         CHECK_ACCESS(ret_ptr);
3951         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3952         FREE((void*)ret);
3953         return ret_conv;
3954 }
3955 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3956         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3957         LDKClosingTransaction closing_tx_var = *closing_tx;
3958         uint32_t closing_tx_ref = 0;
3959         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3960         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3961         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3962         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3963         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3964         if (closing_tx_var.is_owned) {
3965                 closing_tx_ref |= 1;
3966         }
3967         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref);
3968         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3969         CHECK_ACCESS(ret_ptr);
3970         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3971         FREE((void*)ret);
3972         return ret_conv;
3973 }
3974 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3975         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3976         LDKUnsignedChannelAnnouncement msg_var = *msg;
3977         uint32_t msg_ref = 0;
3978         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3979         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3980         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3981         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3982         msg_ref = (uintptr_t)msg_var.inner;
3983         if (msg_var.is_owned) {
3984                 msg_ref |= 1;
3985         }
3986         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 13, (uint32_t)msg_ref);
3987         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3988         CHECK_ACCESS(ret_ptr);
3989         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3990         FREE((void*)ret);
3991         return ret_conv;
3992 }
3993 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3994         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3995         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3996         uint32_t channel_parameters_ref = 0;
3997         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3998         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3999         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4000         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4001         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4002         if (channel_parameters_var.is_owned) {
4003                 channel_parameters_ref |= 1;
4004         }
4005         js_invoke_function_u_u(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref);
4006 }
4007 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
4008         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
4009         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4010 }
4011 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
4012         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4013         atomic_init(&calls->refcnt, 1);
4014         calls->instance_ptr = o;
4015
4016         LDKChannelPublicKeys pubkeys_conv;
4017         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4018         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4019         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4020
4021         LDKBaseSign ret = {
4022                 .this_arg = (void*) calls,
4023                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4024                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4025                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4026                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4027                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4028                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4029                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4030                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4031                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4032                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4033                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4034                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4035                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4036                 .free = LDKBaseSign_JCalls_free,
4037                 .pubkeys = pubkeys_conv,
4038                 .set_pubkeys = NULL,
4039         };
4040         return ret;
4041 }
4042 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
4043         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4044         *res_ptr = LDKBaseSign_init(o, pubkeys);
4045         return (long)res_ptr;
4046 }
4047 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
4048         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4049         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4050         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4051         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
4052         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
4053         return ret_arr;
4054 }
4055
4056 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
4057         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4058         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4059         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4060         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4061         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4062         return ret_arr;
4063 }
4064
4065 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) {
4066         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4067         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4068         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4069         LDKHolderCommitmentTransaction holder_tx_conv;
4070         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4071         holder_tx_conv.is_owned = false;
4072         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4073         LDKCVec_PaymentPreimageZ preimages_constr;
4074         preimages_constr.datalen = preimages->arr_len;
4075         if (preimages_constr.datalen > 0)
4076                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4077         else
4078                 preimages_constr.data = NULL;
4079         int8_tArray* preimages_vals = (void*) preimages->elems;
4080         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4081                 int8_tArray preimages_conv_12 = preimages_vals[m];
4082                 LDKThirtyTwoBytes preimages_conv_12_ref;
4083                 CHECK(preimages_conv_12->arr_len == 32);
4084                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4085                 preimages_constr.data[m] = preimages_conv_12_ref;
4086         }
4087         FREE(preimages);
4088         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4089         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4090         return (uint32_t)ret_conv;
4091 }
4092
4093 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4094         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4095         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4096         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4097         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4098         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4099         return ret_arr;
4100 }
4101
4102 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) {
4103         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4104         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4105         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4106         LDKCommitmentTransaction commitment_tx_conv;
4107         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4108         commitment_tx_conv.is_owned = false;
4109         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4110         LDKCVec_PaymentPreimageZ preimages_constr;
4111         preimages_constr.datalen = preimages->arr_len;
4112         if (preimages_constr.datalen > 0)
4113                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4114         else
4115                 preimages_constr.data = NULL;
4116         int8_tArray* preimages_vals = (void*) preimages->elems;
4117         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4118                 int8_tArray preimages_conv_12 = preimages_vals[m];
4119                 LDKThirtyTwoBytes preimages_conv_12_ref;
4120                 CHECK(preimages_conv_12->arr_len == 32);
4121                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4122                 preimages_constr.data[m] = preimages_conv_12_ref;
4123         }
4124         FREE(preimages);
4125         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4126         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4127         return (uint32_t)ret_conv;
4128 }
4129
4130 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) {
4131         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4132         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4133         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4134         unsigned char secret_arr[32];
4135         CHECK(secret->arr_len == 32);
4136         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4137         unsigned char (*secret_ref)[32] = &secret_arr;
4138         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4139         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4140         return (uint32_t)ret_conv;
4141 }
4142
4143 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) {
4144         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4145         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4146         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4147         LDKHolderCommitmentTransaction commitment_tx_conv;
4148         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4149         commitment_tx_conv.is_owned = false;
4150         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4151         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4152         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4153         return (uint32_t)ret_conv;
4154 }
4155
4156 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) {
4157         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4158         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4159         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4160         LDKTransaction justice_tx_ref;
4161         justice_tx_ref.datalen = justice_tx->arr_len;
4162         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4163         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4164         justice_tx_ref.data_is_owned = true;
4165         unsigned char per_commitment_key_arr[32];
4166         CHECK(per_commitment_key->arr_len == 32);
4167         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4168         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4169         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4170         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4171         return (uint32_t)ret_conv;
4172 }
4173
4174 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) {
4175         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4176         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4177         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4178         LDKTransaction justice_tx_ref;
4179         justice_tx_ref.datalen = justice_tx->arr_len;
4180         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4181         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4182         justice_tx_ref.data_is_owned = true;
4183         unsigned char per_commitment_key_arr[32];
4184         CHECK(per_commitment_key->arr_len == 32);
4185         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4186         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4187         LDKHTLCOutputInCommitment htlc_conv;
4188         htlc_conv.inner = (void*)(htlc & (~1));
4189         htlc_conv.is_owned = false;
4190         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4191         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4192         *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);
4193         return (uint32_t)ret_conv;
4194 }
4195
4196 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) {
4197         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4198         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4199         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4200         LDKTransaction htlc_tx_ref;
4201         htlc_tx_ref.datalen = htlc_tx->arr_len;
4202         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4203         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4204         htlc_tx_ref.data_is_owned = true;
4205         LDKPublicKey per_commitment_point_ref;
4206         CHECK(per_commitment_point->arr_len == 33);
4207         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4208         LDKHTLCOutputInCommitment htlc_conv;
4209         htlc_conv.inner = (void*)(htlc & (~1));
4210         htlc_conv.is_owned = false;
4211         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4212         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4213         *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);
4214         return (uint32_t)ret_conv;
4215 }
4216
4217 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4218         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4219         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4220         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4221         LDKClosingTransaction closing_tx_conv;
4222         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4223         closing_tx_conv.is_owned = false;
4224         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4225         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4226         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4227         return (uint32_t)ret_conv;
4228 }
4229
4230 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4231         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4232         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4233         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4234         LDKUnsignedChannelAnnouncement msg_conv;
4235         msg_conv.inner = (void*)(msg & (~1));
4236         msg_conv.is_owned = false;
4237         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4238         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4239         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4240         return (uint32_t)ret_conv;
4241 }
4242
4243 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
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         LDKChannelTransactionParameters channel_parameters_conv;
4248         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4249         channel_parameters_conv.is_owned = false;
4250         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4251         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4252 }
4253
4254 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4255         if (this_arg->set_pubkeys != NULL)
4256                 this_arg->set_pubkeys(this_arg);
4257         return this_arg->pubkeys;
4258 }
4259 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4260         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4261         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4262         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4263         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4264         uint32_t ret_ref = 0;
4265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4268         ret_ref = (uintptr_t)ret_var.inner;
4269         if (ret_var.is_owned) {
4270                 ret_ref |= 1;
4271         }
4272         return ret_ref;
4273 }
4274
4275 typedef struct LDKSign_JCalls {
4276         atomic_size_t refcnt;
4277         uint32_t instance_ptr;
4278         LDKBaseSign_JCalls* BaseSign;
4279 } LDKSign_JCalls;
4280 static void LDKSign_JCalls_free(void* this_arg) {
4281         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4282         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4283                 FREE(j_calls);
4284         }
4285 }
4286 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4287         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4288         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 15);
4289         LDKCVec_u8Z ret_ref;
4290         ret_ref.datalen = ret->arr_len;
4291         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4292         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4293         return ret_ref;
4294 }
4295 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4296         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4297         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4298         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4299 }
4300 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4301         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4302         atomic_init(&calls->refcnt, 1);
4303         calls->instance_ptr = o;
4304
4305         LDKChannelPublicKeys pubkeys_conv;
4306         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4307         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4308         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4309
4310         LDKSign ret = {
4311                 .this_arg = (void*) calls,
4312                 .write = write_LDKSign_jcall,
4313                 .cloned = LDKSign_JCalls_cloned,
4314                 .free = LDKSign_JCalls_free,
4315                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4316         };
4317         calls->BaseSign = ret.BaseSign.this_arg;
4318         return ret;
4319 }
4320 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4321         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4322         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4323         return (long)res_ptr;
4324 }
4325 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4326         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4327         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4328         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4329         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4330         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4331         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4332         CVec_u8Z_free(ret_var);
4333         return ret_arr;
4334 }
4335
4336 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4337 CHECK(owner->result_ok);
4338         return Sign_clone(&*owner->contents.result);
4339 }
4340 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4341         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4342         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4343         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4344         return (uint32_t)ret_ret;
4345 }
4346
4347 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4348 CHECK(!owner->result_ok);
4349         return DecodeError_clone(&*owner->contents.err);
4350 }
4351 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4352         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4353         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4354         uint32_t ret_ref = 0;
4355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4358         ret_ref = (uintptr_t)ret_var.inner;
4359         if (ret_var.is_owned) {
4360                 ret_ref |= 1;
4361         }
4362         return ret_ref;
4363 }
4364
4365 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4366 CHECK(owner->result_ok);
4367         return *owner->contents.result;
4368 }
4369 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4370         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4371         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4372         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4373         return ret_arr;
4374 }
4375
4376 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4377 CHECK(!owner->result_ok);
4378         return *owner->contents.err;
4379 }
4380 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4381         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4382         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4383 }
4384
4385 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4386         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4387         for (size_t i = 0; i < ret.datalen; i++) {
4388                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4389         }
4390         return ret;
4391 }
4392 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4393 CHECK(owner->result_ok);
4394         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4395 }
4396 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4397         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4398         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4399         ptrArray ret_arr = NULL;
4400         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4401         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
4402         for (size_t m = 0; m < ret_var.datalen; m++) {
4403                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4404                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4405                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4406                 CVec_u8Z_free(ret_conv_12_var);
4407                 ret_arr_ptr[m] = ret_conv_12_arr;
4408         }
4409         
4410         FREE(ret_var.data);
4411         return ret_arr;
4412 }
4413
4414 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4415 CHECK(!owner->result_ok);
4416         return *owner->contents.err;
4417 }
4418 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4419         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4420         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4421 }
4422
4423 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4424 CHECK(owner->result_ok);
4425         return InMemorySigner_clone(&*owner->contents.result);
4426 }
4427 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4428         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4429         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4430         uint32_t ret_ref = 0;
4431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4434         ret_ref = (uintptr_t)ret_var.inner;
4435         if (ret_var.is_owned) {
4436                 ret_ref |= 1;
4437         }
4438         return ret_ref;
4439 }
4440
4441 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4442 CHECK(!owner->result_ok);
4443         return DecodeError_clone(&*owner->contents.err);
4444 }
4445 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4446         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4447         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4448         uint32_t ret_ref = 0;
4449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4452         ret_ref = (uintptr_t)ret_var.inner;
4453         if (ret_var.is_owned) {
4454                 ret_ref |= 1;
4455         }
4456         return ret_ref;
4457 }
4458
4459 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4460         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4461         for (size_t i = 0; i < ret.datalen; i++) {
4462                 ret.data[i] = TxOut_clone(&orig->data[i]);
4463         }
4464         return ret;
4465 }
4466 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4467 CHECK(owner->result_ok);
4468         return *owner->contents.result;
4469 }
4470 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4471         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4472         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4473         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4474         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4475         return ret_arr;
4476 }
4477
4478 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4479 CHECK(!owner->result_ok);
4480         return *owner->contents.err;
4481 }
4482 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4483         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4484         CResult_TransactionNoneZ_get_err(owner_conv);
4485 }
4486
4487 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4488         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4489         switch(obj->tag) {
4490                 case LDKCOption_u16Z_Some: return 0;
4491                 case LDKCOption_u16Z_None: return 1;
4492                 default: abort();
4493         }
4494 }
4495 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4496         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4497         assert(obj->tag == LDKCOption_u16Z_Some);
4498                         int16_t some_conv = obj->some;
4499         return some_conv;
4500 }
4501 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4502         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4503         switch(obj->tag) {
4504                 case LDKAPIError_APIMisuseError: return 0;
4505                 case LDKAPIError_FeeRateTooHigh: return 1;
4506                 case LDKAPIError_RouteError: return 2;
4507                 case LDKAPIError_ChannelUnavailable: return 3;
4508                 case LDKAPIError_MonitorUpdateFailed: return 4;
4509                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4510                 default: abort();
4511         }
4512 }
4513 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4514         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4515         assert(obj->tag == LDKAPIError_APIMisuseError);
4516                         LDKStr err_str = obj->api_misuse_error.err;
4517                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4518         return err_conv;
4519 }
4520 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4521         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4522         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4523                         LDKStr err_str = obj->fee_rate_too_high.err;
4524                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4525         return err_conv;
4526 }
4527 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4528         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4529         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4530                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4531         return feerate_conv;
4532 }
4533 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4534         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4535         assert(obj->tag == LDKAPIError_RouteError);
4536                         LDKStr err_str = obj->route_error.err;
4537                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4538         return err_conv;
4539 }
4540 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4541         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4542         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4543                         LDKStr err_str = obj->channel_unavailable.err;
4544                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4545         return err_conv;
4546 }
4547 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4548         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4549         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4550                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4551                         uint32_t script_ref = 0;
4552                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4553                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4554                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4555                         script_ref = (uintptr_t)script_var.inner & ~1;
4556         return script_ref;
4557 }
4558 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4559 CHECK(owner->result_ok);
4560         return *owner->contents.result;
4561 }
4562 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4563         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4564         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4565 }
4566
4567 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4568 CHECK(!owner->result_ok);
4569         return APIError_clone(&*owner->contents.err);
4570 }
4571 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4572         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4573         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4574         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4575         uint32_t ret_ref = (uintptr_t)ret_copy;
4576         return ret_ref;
4577 }
4578
4579 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4580         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4581         for (size_t i = 0; i < ret.datalen; i++) {
4582                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4583         }
4584         return ret;
4585 }
4586 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4587         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4588         for (size_t i = 0; i < ret.datalen; i++) {
4589                 ret.data[i] = APIError_clone(&orig->data[i]);
4590         }
4591         return ret;
4592 }
4593 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4594 CHECK(owner->result_ok);
4595         return ThirtyTwoBytes_clone(&*owner->contents.result);
4596 }
4597 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4598         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4599         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4600         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4601         return ret_arr;
4602 }
4603
4604 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4605 CHECK(!owner->result_ok);
4606         return APIError_clone(&*owner->contents.err);
4607 }
4608 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4609         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4610         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4611         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4612         uint32_t ret_ref = (uintptr_t)ret_copy;
4613         return ret_ref;
4614 }
4615
4616 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4617         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4618         switch(obj->tag) {
4619                 case LDKPaymentSendFailure_ParameterError: return 0;
4620                 case LDKPaymentSendFailure_PathParameterError: return 1;
4621                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4622                 case LDKPaymentSendFailure_PartialFailure: return 3;
4623                 default: abort();
4624         }
4625 }
4626 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4627         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4628         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4629                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4630         return parameter_error_ref;
4631 }
4632 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4633         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4634         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4635                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4636                         uint32_tArray path_parameter_error_arr = NULL;
4637                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4638                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
4639                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4640                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4641                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4642                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4643                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4644                         }
4645                         
4646         return path_parameter_error_arr;
4647 }
4648 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4649         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4650         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4651                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4652                         uint32_tArray all_failed_retry_safe_arr = NULL;
4653                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4654                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
4655                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4656                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4657                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4658                         }
4659                         
4660         return all_failed_retry_safe_arr;
4661 }
4662 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4663         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4664         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4665                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4666                         uint32_tArray results_arr = NULL;
4667                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4668                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
4669                         for (size_t w = 0; w < results_var.datalen; w++) {
4670                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4671                                 *results_conv_22_conv = results_var.data[w];
4672                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4673                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4674                         }
4675                         
4676         return results_arr;
4677 }
4678 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4679         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4680         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4681                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4682                         uint32_t failed_paths_retry_ref = 0;
4683                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4684                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4685                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4686                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4687                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4688                         }
4689         return failed_paths_retry_ref;
4690 }
4691 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4692         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4693         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4694                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4695                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4696         return payment_id_arr;
4697 }
4698 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4699 CHECK(owner->result_ok);
4700         return ThirtyTwoBytes_clone(&*owner->contents.result);
4701 }
4702 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4703         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4704         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4705         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4706         return ret_arr;
4707 }
4708
4709 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4710 CHECK(!owner->result_ok);
4711         return PaymentSendFailure_clone(&*owner->contents.err);
4712 }
4713 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4714         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4715         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4716         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4717         uint32_t ret_ref = (uintptr_t)ret_copy;
4718         return ret_ref;
4719 }
4720
4721 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4722 CHECK(owner->result_ok);
4723         return *owner->contents.result;
4724 }
4725 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4726         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4727         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4728 }
4729
4730 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4731 CHECK(!owner->result_ok);
4732         return PaymentSendFailure_clone(&*owner->contents.err);
4733 }
4734 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4735         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4736         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4737         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4738         uint32_t ret_ref = (uintptr_t)ret_copy;
4739         return ret_ref;
4740 }
4741
4742 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4743         return ThirtyTwoBytes_clone(&owner->a);
4744 }
4745 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4746         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4747         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4748         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4749         return ret_arr;
4750 }
4751
4752 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4753         return ThirtyTwoBytes_clone(&owner->b);
4754 }
4755 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4756         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4757         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4758         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4759         return ret_arr;
4760 }
4761
4762 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4763 CHECK(owner->result_ok);
4764         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4765 }
4766 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4767         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4768         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4769         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4770         return ((uint32_t)ret_conv);
4771 }
4772
4773 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4774 CHECK(!owner->result_ok);
4775         return PaymentSendFailure_clone(&*owner->contents.err);
4776 }
4777 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4778         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4779         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4780         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4781         uint32_t ret_ref = (uintptr_t)ret_copy;
4782         return ret_ref;
4783 }
4784
4785 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4786         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4787         for (size_t i = 0; i < ret.datalen; i++) {
4788                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4789         }
4790         return ret;
4791 }
4792 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4793         return ThirtyTwoBytes_clone(&owner->a);
4794 }
4795 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4796         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4797         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4798         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4799         return ret_arr;
4800 }
4801
4802 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4803         return ThirtyTwoBytes_clone(&owner->b);
4804 }
4805 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4806         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4807         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4808         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4809         return ret_arr;
4810 }
4811
4812 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4813 CHECK(owner->result_ok);
4814         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4815 }
4816 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4817         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4818         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4819         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4820         return ((uint32_t)ret_conv);
4821 }
4822
4823 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4824 CHECK(!owner->result_ok);
4825         return *owner->contents.err;
4826 }
4827 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4828         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4829         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4830 }
4831
4832 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4833 CHECK(owner->result_ok);
4834         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4835 }
4836 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4837         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4838         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4839         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4840         return ((uint32_t)ret_conv);
4841 }
4842
4843 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4844 CHECK(!owner->result_ok);
4845         return APIError_clone(&*owner->contents.err);
4846 }
4847 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4848         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4849         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4850         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4851         uint32_t ret_ref = (uintptr_t)ret_copy;
4852         return ret_ref;
4853 }
4854
4855 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4856 CHECK(owner->result_ok);
4857         return ThirtyTwoBytes_clone(&*owner->contents.result);
4858 }
4859 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4860         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4861         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4862         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4863         return ret_arr;
4864 }
4865
4866 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4867 CHECK(!owner->result_ok);
4868         return *owner->contents.err;
4869 }
4870 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4871         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4872         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4873 }
4874
4875 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4876 CHECK(owner->result_ok);
4877         return ThirtyTwoBytes_clone(&*owner->contents.result);
4878 }
4879 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4880         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4881         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4882         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4883         return ret_arr;
4884 }
4885
4886 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4887 CHECK(!owner->result_ok);
4888         return APIError_clone(&*owner->contents.err);
4889 }
4890 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4891         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4892         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4893         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4894         uint32_t ret_ref = (uintptr_t)ret_copy;
4895         return ret_ref;
4896 }
4897
4898 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4899 CHECK(owner->result_ok);
4900         return ThirtyTwoBytes_clone(&*owner->contents.result);
4901 }
4902 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4903         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4904         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4905         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4906         return ret_arr;
4907 }
4908
4909 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4910 CHECK(!owner->result_ok);
4911         return APIError_clone(&*owner->contents.err);
4912 }
4913 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4914         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4915         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4916         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4917         uint32_t ret_ref = (uintptr_t)ret_copy;
4918         return ret_ref;
4919 }
4920
4921 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4922 CHECK(owner->result_ok);
4923         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4924 }
4925 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4926         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4927         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4928         uint32_t ret_ref = 0;
4929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4932         ret_ref = (uintptr_t)ret_var.inner;
4933         if (ret_var.is_owned) {
4934                 ret_ref |= 1;
4935         }
4936         return ret_ref;
4937 }
4938
4939 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4940 CHECK(!owner->result_ok);
4941         return DecodeError_clone(&*owner->contents.err);
4942 }
4943 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4944         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4945         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4946         uint32_t ret_ref = 0;
4947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4950         ret_ref = (uintptr_t)ret_var.inner;
4951         if (ret_var.is_owned) {
4952                 ret_ref |= 1;
4953         }
4954         return ret_ref;
4955 }
4956
4957 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4958 CHECK(owner->result_ok);
4959         return ChannelCounterparty_clone(&*owner->contents.result);
4960 }
4961 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4962         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4963         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4964         uint32_t ret_ref = 0;
4965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4968         ret_ref = (uintptr_t)ret_var.inner;
4969         if (ret_var.is_owned) {
4970                 ret_ref |= 1;
4971         }
4972         return ret_ref;
4973 }
4974
4975 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4976 CHECK(!owner->result_ok);
4977         return DecodeError_clone(&*owner->contents.err);
4978 }
4979 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4980         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4981         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4982         uint32_t ret_ref = 0;
4983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4986         ret_ref = (uintptr_t)ret_var.inner;
4987         if (ret_var.is_owned) {
4988                 ret_ref |= 1;
4989         }
4990         return ret_ref;
4991 }
4992
4993 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4994 CHECK(owner->result_ok);
4995         return ChannelDetails_clone(&*owner->contents.result);
4996 }
4997 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4998         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4999         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5000         uint32_t ret_ref = 0;
5001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5004         ret_ref = (uintptr_t)ret_var.inner;
5005         if (ret_var.is_owned) {
5006                 ret_ref |= 1;
5007         }
5008         return ret_ref;
5009 }
5010
5011 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5012 CHECK(!owner->result_ok);
5013         return DecodeError_clone(&*owner->contents.err);
5014 }
5015 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
5016         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5017         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5018         uint32_t ret_ref = 0;
5019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5022         ret_ref = (uintptr_t)ret_var.inner;
5023         if (ret_var.is_owned) {
5024                 ret_ref |= 1;
5025         }
5026         return ret_ref;
5027 }
5028
5029 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5030 CHECK(owner->result_ok);
5031         return PhantomRouteHints_clone(&*owner->contents.result);
5032 }
5033 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
5034         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5035         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5036         uint32_t ret_ref = 0;
5037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5040         ret_ref = (uintptr_t)ret_var.inner;
5041         if (ret_var.is_owned) {
5042                 ret_ref |= 1;
5043         }
5044         return ret_ref;
5045 }
5046
5047 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5048 CHECK(!owner->result_ok);
5049         return DecodeError_clone(&*owner->contents.err);
5050 }
5051 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
5052         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5053         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5054         uint32_t ret_ref = 0;
5055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5058         ret_ref = (uintptr_t)ret_var.inner;
5059         if (ret_var.is_owned) {
5060                 ret_ref |= 1;
5061         }
5062         return ret_ref;
5063 }
5064
5065 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5066         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5067         for (size_t i = 0; i < ret.datalen; i++) {
5068                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5069         }
5070         return ret;
5071 }
5072 typedef struct LDKWatch_JCalls {
5073         atomic_size_t refcnt;
5074         uint32_t instance_ptr;
5075 } LDKWatch_JCalls;
5076 static void LDKWatch_JCalls_free(void* this_arg) {
5077         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5078         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5079                 FREE(j_calls);
5080         }
5081 }
5082 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5083         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5084         LDKOutPoint funding_txo_var = funding_txo;
5085         uint32_t funding_txo_ref = 0;
5086         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5087         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5088         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5089         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5090         if (funding_txo_var.is_owned) {
5091                 funding_txo_ref |= 1;
5092         }
5093         LDKChannelMonitor monitor_var = monitor;
5094         uint32_t monitor_ref = 0;
5095         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5096         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5097         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5098         monitor_ref = (uintptr_t)monitor_var.inner;
5099         if (monitor_var.is_owned) {
5100                 monitor_ref |= 1;
5101         }
5102         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 16, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
5103         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5104         CHECK_ACCESS(ret_ptr);
5105         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5106         FREE((void*)ret);
5107         return ret_conv;
5108 }
5109 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5110         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5111         LDKOutPoint funding_txo_var = funding_txo;
5112         uint32_t funding_txo_ref = 0;
5113         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5114         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5115         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5116         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5117         if (funding_txo_var.is_owned) {
5118                 funding_txo_ref |= 1;
5119         }
5120         LDKChannelMonitorUpdate update_var = update;
5121         uint32_t update_ref = 0;
5122         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5123         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5124         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5125         update_ref = (uintptr_t)update_var.inner;
5126         if (update_var.is_owned) {
5127                 update_ref |= 1;
5128         }
5129         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 17, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
5130         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5131         CHECK_ACCESS(ret_ptr);
5132         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5133         FREE((void*)ret);
5134         return ret_conv;
5135 }
5136 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5137         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5138         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 18);
5139         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
5140         ret_constr.datalen = ret->arr_len;
5141         if (ret_constr.datalen > 0)
5142                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
5143         else
5144                 ret_constr.data = NULL;
5145         uint32_t* ret_vals = ret->elems;
5146         for (size_t m = 0; m < ret_constr.datalen; m++) {
5147                 uint32_t ret_conv_38 = ret_vals[m];
5148                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
5149                 CHECK_ACCESS(ret_conv_38_ptr);
5150                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
5151                 FREE((void*)ret_conv_38);
5152                 ret_constr.data[m] = ret_conv_38_conv;
5153         }
5154         FREE(ret);
5155         return ret_constr;
5156 }
5157 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5158         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5159         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5160 }
5161 static inline LDKWatch LDKWatch_init (JSValue o) {
5162         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5163         atomic_init(&calls->refcnt, 1);
5164         calls->instance_ptr = o;
5165
5166         LDKWatch ret = {
5167                 .this_arg = (void*) calls,
5168                 .watch_channel = watch_channel_LDKWatch_jcall,
5169                 .update_channel = update_channel_LDKWatch_jcall,
5170                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5171                 .free = LDKWatch_JCalls_free,
5172         };
5173         return ret;
5174 }
5175 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5176         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5177         *res_ptr = LDKWatch_init(o);
5178         return (long)res_ptr;
5179 }
5180 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5181         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5182         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5183         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5184         LDKOutPoint funding_txo_conv;
5185         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5186         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5187         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5188         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5189         LDKChannelMonitor monitor_conv;
5190         monitor_conv.inner = (void*)(monitor & (~1));
5191         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5192         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5193         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5194         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5195         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5196         return (uint32_t)ret_conv;
5197 }
5198
5199 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5202         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5203         LDKOutPoint funding_txo_conv;
5204         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5205         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5206         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5207         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5208         LDKChannelMonitorUpdate update_conv;
5209         update_conv.inner = (void*)(update & (~1));
5210         update_conv.is_owned = (update & 1) || (update == 0);
5211         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5212         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5213         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5214         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5215         return (uint32_t)ret_conv;
5216 }
5217
5218 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5219         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5221         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5222         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5223         uint32_tArray ret_arr = NULL;
5224         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5225         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5226         for (size_t m = 0; m < ret_var.datalen; m++) {
5227                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
5228                 *ret_conv_38_conv = ret_var.data[m];
5229                 ret_arr_ptr[m] = ((uint32_t)ret_conv_38_conv);
5230         }
5231         
5232         FREE(ret_var.data);
5233         return ret_arr;
5234 }
5235
5236 typedef struct LDKBroadcasterInterface_JCalls {
5237         atomic_size_t refcnt;
5238         uint32_t instance_ptr;
5239 } LDKBroadcasterInterface_JCalls;
5240 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5241         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5242         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5243                 FREE(j_calls);
5244         }
5245 }
5246 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5247         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5248         LDKTransaction tx_var = tx;
5249         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5250         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5251         Transaction_free(tx_var);
5252         js_invoke_function_u_u(j_calls->instance_ptr, 19, (uint32_t)tx_arr);
5253 }
5254 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5255         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5256         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5257 }
5258 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5259         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5260         atomic_init(&calls->refcnt, 1);
5261         calls->instance_ptr = o;
5262
5263         LDKBroadcasterInterface ret = {
5264                 .this_arg = (void*) calls,
5265                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5266                 .free = LDKBroadcasterInterface_JCalls_free,
5267         };
5268         return ret;
5269 }
5270 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5271         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5272         *res_ptr = LDKBroadcasterInterface_init(o);
5273         return (long)res_ptr;
5274 }
5275 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5276         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5277         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5278         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5279         LDKTransaction tx_ref;
5280         tx_ref.datalen = tx->arr_len;
5281         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5282         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5283         tx_ref.data_is_owned = true;
5284         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5285 }
5286
5287 typedef struct LDKKeysInterface_JCalls {
5288         atomic_size_t refcnt;
5289         uint32_t instance_ptr;
5290 } LDKKeysInterface_JCalls;
5291 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5292         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5293         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5294                 FREE(j_calls);
5295         }
5296 }
5297 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5298         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5299         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5300         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 20, (uint32_t)recipient_conv);
5301         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5302         CHECK_ACCESS(ret_ptr);
5303         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5304         FREE((void*)ret);
5305         return ret_conv;
5306 }
5307 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5308         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5309         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 21);
5310         LDKCVec_u8Z ret_ref;
5311         ret_ref.datalen = ret->arr_len;
5312         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5313         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5314         return ret_ref;
5315 }
5316 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5317         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5318         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 22);
5319         LDKShutdownScript ret_conv;
5320         ret_conv.inner = (void*)(ret & (~1));
5321         ret_conv.is_owned = (ret & 1) || (ret == 0);
5322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5323         return ret_conv;
5324 }
5325 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5326         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5327         jboolean inbound_conv = inbound;
5328         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5329         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 23, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
5330         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5331         CHECK_ACCESS(ret_ptr);
5332         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5333         FREE((void*)ret);
5334         return ret_conv;
5335 }
5336 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5337         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5338         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 24);
5339         LDKThirtyTwoBytes ret_ref;
5340         CHECK(ret->arr_len == 32);
5341         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5342         return ret_ref;
5343 }
5344 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5345         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5346         LDKu8slice reader_var = reader;
5347         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5348         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5349         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 25, (uint32_t)reader_arr);
5350         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5351         CHECK_ACCESS(ret_ptr);
5352         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5353         FREE((void*)ret);
5354         return ret_conv;
5355 }
5356 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5357         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5358         LDKu8slice hrp_bytes_var = hrp_bytes;
5359         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5360         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5361         LDKCVec_u5Z invoice_data_var = invoice_data;
5362         ptrArray invoice_data_arr = NULL;
5363         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5364         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
5365         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5366                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5367                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5368         }
5369         
5370         FREE(invoice_data_var.data);
5371         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5372         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);
5373         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5374         CHECK_ACCESS(ret_ptr);
5375         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5376         FREE((void*)ret);
5377         return ret_conv;
5378 }
5379 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5380         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5381         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 27);
5382         LDKThirtyTwoBytes ret_ref;
5383         CHECK(ret->arr_len == 32);
5384         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5385         return ret_ref;
5386 }
5387 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5388         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5389         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5390 }
5391 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5392         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5393         atomic_init(&calls->refcnt, 1);
5394         calls->instance_ptr = o;
5395
5396         LDKKeysInterface ret = {
5397                 .this_arg = (void*) calls,
5398                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5399                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5400                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5401                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5402                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5403                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5404                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5405                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5406                 .free = LDKKeysInterface_JCalls_free,
5407         };
5408         return ret;
5409 }
5410 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5411         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5412         *res_ptr = LDKKeysInterface_init(o);
5413         return (long)res_ptr;
5414 }
5415 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5416         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5417         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5418         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5419         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5420         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5421         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5422         return (uint32_t)ret_conv;
5423 }
5424
5425 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5426         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5428         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5429         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5430         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5431         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5432         CVec_u8Z_free(ret_var);
5433         return ret_arr;
5434 }
5435
5436 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5437         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5439         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5440         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5441         uint32_t ret_ref = 0;
5442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5445         ret_ref = (uintptr_t)ret_var.inner;
5446         if (ret_var.is_owned) {
5447                 ret_ref |= 1;
5448         }
5449         return ret_ref;
5450 }
5451
5452 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) {
5453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5455         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5456         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5457         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5458         return (uint32_t)ret_ret;
5459 }
5460
5461 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5462         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5463         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5464         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5465         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5466         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5467         return ret_arr;
5468 }
5469
5470 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5471         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5472         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5473         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5474         LDKu8slice reader_ref;
5475         reader_ref.datalen = reader->arr_len;
5476         reader_ref.data = reader->elems;
5477         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5478         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5479         FREE(reader);
5480         return (uint32_t)ret_conv;
5481 }
5482
5483 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) {
5484         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5485         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5486         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5487         LDKu8slice hrp_bytes_ref;
5488         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5489         hrp_bytes_ref.data = hrp_bytes->elems;
5490         LDKCVec_u5Z invoice_data_constr;
5491         invoice_data_constr.datalen = invoice_data->arr_len;
5492         if (invoice_data_constr.datalen > 0)
5493                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5494         else
5495                 invoice_data_constr.data = NULL;
5496         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5497         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5498                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5499                 
5500                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5501         }
5502         FREE(invoice_data);
5503         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5504         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5505         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5506         FREE(hrp_bytes);
5507         return (uint32_t)ret_conv;
5508 }
5509
5510 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5511         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5512         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5513         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5514         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5515         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5516         return ret_arr;
5517 }
5518
5519 typedef struct LDKFeeEstimator_JCalls {
5520         atomic_size_t refcnt;
5521         uint32_t instance_ptr;
5522 } LDKFeeEstimator_JCalls;
5523 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5524         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5525         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5526                 FREE(j_calls);
5527         }
5528 }
5529 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5530         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5531         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5532         return js_invoke_function_u_u(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv);
5533 }
5534 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5535         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5536         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5537 }
5538 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5539         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5540         atomic_init(&calls->refcnt, 1);
5541         calls->instance_ptr = o;
5542
5543         LDKFeeEstimator ret = {
5544                 .this_arg = (void*) calls,
5545                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5546                 .free = LDKFeeEstimator_JCalls_free,
5547         };
5548         return ret;
5549 }
5550 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5551         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5552         *res_ptr = LDKFeeEstimator_init(o);
5553         return (long)res_ptr;
5554 }
5555 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) {
5556         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5557         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5558         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5559         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5560         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5561         return ret_conv;
5562 }
5563
5564 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5565         return ThirtyTwoBytes_clone(&owner->a);
5566 }
5567 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5568         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5569         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5570         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5571         return ret_arr;
5572 }
5573
5574 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5575         return &owner->b;
5576 }
5577 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5578         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5579         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5580         uint32_t ret_ref = 0;
5581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5584         ret_ref = (uintptr_t)ret_var.inner & ~1;
5585         return ret_ref;
5586 }
5587
5588 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5589 CHECK(owner->result_ok);
5590         return &*owner->contents.result;
5591 }
5592 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5593         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5594         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5595         return ret_ret;
5596 }
5597
5598 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5599 CHECK(!owner->result_ok);
5600         return DecodeError_clone(&*owner->contents.err);
5601 }
5602 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5603         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5604         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5605         uint32_t ret_ref = 0;
5606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5609         ret_ref = (uintptr_t)ret_var.inner;
5610         if (ret_var.is_owned) {
5611                 ret_ref |= 1;
5612         }
5613         return ret_ref;
5614 }
5615
5616 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5617 CHECK(owner->result_ok);
5618         return ChannelConfig_clone(&*owner->contents.result);
5619 }
5620 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5621         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5622         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5623         uint32_t ret_ref = 0;
5624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5627         ret_ref = (uintptr_t)ret_var.inner;
5628         if (ret_var.is_owned) {
5629                 ret_ref |= 1;
5630         }
5631         return ret_ref;
5632 }
5633
5634 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5635 CHECK(!owner->result_ok);
5636         return DecodeError_clone(&*owner->contents.err);
5637 }
5638 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5639         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5640         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5641         uint32_t ret_ref = 0;
5642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5645         ret_ref = (uintptr_t)ret_var.inner;
5646         if (ret_var.is_owned) {
5647                 ret_ref |= 1;
5648         }
5649         return ret_ref;
5650 }
5651
5652 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5653 CHECK(owner->result_ok);
5654         return OutPoint_clone(&*owner->contents.result);
5655 }
5656 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5657         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5658         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5659         uint32_t ret_ref = 0;
5660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5663         ret_ref = (uintptr_t)ret_var.inner;
5664         if (ret_var.is_owned) {
5665                 ret_ref |= 1;
5666         }
5667         return ret_ref;
5668 }
5669
5670 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5671 CHECK(!owner->result_ok);
5672         return DecodeError_clone(&*owner->contents.err);
5673 }
5674 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5675         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5676         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5677         uint32_t ret_ref = 0;
5678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5681         ret_ref = (uintptr_t)ret_var.inner;
5682         if (ret_var.is_owned) {
5683                 ret_ref |= 1;
5684         }
5685         return ret_ref;
5686 }
5687
5688 typedef struct LDKType_JCalls {
5689         atomic_size_t refcnt;
5690         uint32_t instance_ptr;
5691 } LDKType_JCalls;
5692 static void LDKType_JCalls_free(void* this_arg) {
5693         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5694         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5695                 FREE(j_calls);
5696         }
5697 }
5698 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5699         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5700         return js_invoke_function_u_(j_calls->instance_ptr, 29);
5701 }
5702 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5703         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5704         jstring ret = (jstring)js_invoke_function_u_(j_calls->instance_ptr, 30);
5705         LDKStr ret_conv = str_ref_to_owned_c(ret);
5706         return ret_conv;
5707 }
5708 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5709         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5710         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 31);
5711         LDKCVec_u8Z ret_ref;
5712         ret_ref.datalen = ret->arr_len;
5713         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5714         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5715         return ret_ref;
5716 }
5717 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5718         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5719         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5720 }
5721 static inline LDKType LDKType_init (JSValue o) {
5722         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5723         atomic_init(&calls->refcnt, 1);
5724         calls->instance_ptr = o;
5725
5726         LDKType ret = {
5727                 .this_arg = (void*) calls,
5728                 .type_id = type_id_LDKType_jcall,
5729                 .debug_str = debug_str_LDKType_jcall,
5730                 .write = write_LDKType_jcall,
5731                 .cloned = LDKType_JCalls_cloned,
5732                 .free = LDKType_JCalls_free,
5733         };
5734         return ret;
5735 }
5736 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5737         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5738         *res_ptr = LDKType_init(o);
5739         return (long)res_ptr;
5740 }
5741 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5742         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5743         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5744         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5745         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5746         return ret_conv;
5747 }
5748
5749 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5750         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5751         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5752         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5753         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5754         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5755         Str_free(ret_str);
5756         return ret_conv;
5757 }
5758
5759 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5760         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5761         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5762         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5763         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5764         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5765         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5766         CVec_u8Z_free(ret_var);
5767         return ret_arr;
5768 }
5769
5770 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5771         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5772         switch(obj->tag) {
5773                 case LDKCOption_TypeZ_Some: return 0;
5774                 case LDKCOption_TypeZ_None: return 1;
5775                 default: abort();
5776         }
5777 }
5778 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5779         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5780         assert(obj->tag == LDKCOption_TypeZ_Some);
5781                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5782                         *some_ret = Type_clone(&obj->some);
5783         return (uint32_t)some_ret;
5784 }
5785 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5786 CHECK(owner->result_ok);
5787         return COption_TypeZ_clone(&*owner->contents.result);
5788 }
5789 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5790         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5791         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5792         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5793         uint32_t ret_ref = (uintptr_t)ret_copy;
5794         return ret_ref;
5795 }
5796
5797 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5798 CHECK(!owner->result_ok);
5799         return DecodeError_clone(&*owner->contents.err);
5800 }
5801 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5802         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5803         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5804         uint32_t ret_ref = 0;
5805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5808         ret_ref = (uintptr_t)ret_var.inner;
5809         if (ret_var.is_owned) {
5810                 ret_ref |= 1;
5811         }
5812         return ret_ref;
5813 }
5814
5815 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5816         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5817         switch(obj->tag) {
5818                 case LDKPaymentError_Invoice: return 0;
5819                 case LDKPaymentError_Routing: return 1;
5820                 case LDKPaymentError_Sending: return 2;
5821                 default: abort();
5822         }
5823 }
5824 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5825         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5826         assert(obj->tag == LDKPaymentError_Invoice);
5827                         LDKStr invoice_str = obj->invoice;
5828                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5829         return invoice_conv;
5830 }
5831 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5832         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5833         assert(obj->tag == LDKPaymentError_Routing);
5834                         LDKLightningError routing_var = obj->routing;
5835                         uint32_t routing_ref = 0;
5836                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5837                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5838                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5839                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5840         return routing_ref;
5841 }
5842 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5843         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5844         assert(obj->tag == LDKPaymentError_Sending);
5845                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5846         return sending_ref;
5847 }
5848 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5849 CHECK(owner->result_ok);
5850         return ThirtyTwoBytes_clone(&*owner->contents.result);
5851 }
5852 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5853         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5854         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5855         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5856         return ret_arr;
5857 }
5858
5859 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5860 CHECK(!owner->result_ok);
5861         return PaymentError_clone(&*owner->contents.err);
5862 }
5863 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5864         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5865         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5866         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5867         uint32_t ret_ref = (uintptr_t)ret_copy;
5868         return ret_ref;
5869 }
5870
5871 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5872         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5873         switch(obj->tag) {
5874                 case LDKParseError_Bech32Error: return 0;
5875                 case LDKParseError_ParseAmountError: return 1;
5876                 case LDKParseError_MalformedSignature: return 2;
5877                 case LDKParseError_BadPrefix: return 3;
5878                 case LDKParseError_UnknownCurrency: return 4;
5879                 case LDKParseError_UnknownSiPrefix: return 5;
5880                 case LDKParseError_MalformedHRP: return 6;
5881                 case LDKParseError_TooShortDataPart: return 7;
5882                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5883                 case LDKParseError_DescriptionDecodeError: return 9;
5884                 case LDKParseError_PaddingError: return 10;
5885                 case LDKParseError_IntegerOverflowError: return 11;
5886                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5887                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5888                 case LDKParseError_InvalidScriptHashLength: return 14;
5889                 case LDKParseError_InvalidRecoveryId: return 15;
5890                 case LDKParseError_InvalidSliceLength: return 16;
5891                 case LDKParseError_Skip: return 17;
5892                 default: abort();
5893         }
5894 }
5895 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5896         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5897         assert(obj->tag == LDKParseError_Bech32Error);
5898                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5899         return bech32_error_ref;
5900 }
5901 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5902         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5903         assert(obj->tag == LDKParseError_ParseAmountError);
5904                         /*obj->parse_amount_error*/
5905         return 0;
5906 }
5907 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5908         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5909         assert(obj->tag == LDKParseError_MalformedSignature);
5910                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5911         return malformed_signature_conv;
5912 }
5913 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5914         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5915         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5916                         /*obj->description_decode_error*/
5917         return 0;
5918 }
5919 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5920         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5921         assert(obj->tag == LDKParseError_InvalidSliceLength);
5922                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5923                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5924         return invalid_slice_length_conv;
5925 }
5926 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5927 CHECK(owner->result_ok);
5928         return SiPrefix_clone(&*owner->contents.result);
5929 }
5930 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5931         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5932         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5933         return ret_conv;
5934 }
5935
5936 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5937 CHECK(!owner->result_ok);
5938         return ParseError_clone(&*owner->contents.err);
5939 }
5940 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5941         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5942         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5943         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5944         uint32_t ret_ref = (uintptr_t)ret_copy;
5945         return ret_ref;
5946 }
5947
5948 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5949         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5950         switch(obj->tag) {
5951                 case LDKParseOrSemanticError_ParseError: return 0;
5952                 case LDKParseOrSemanticError_SemanticError: return 1;
5953                 default: abort();
5954         }
5955 }
5956 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5957         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5958         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5959                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5960         return parse_error_ref;
5961 }
5962 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5963         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5964         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5965                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5966         return semantic_error_conv;
5967 }
5968 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5969 CHECK(owner->result_ok);
5970         return Invoice_clone(&*owner->contents.result);
5971 }
5972 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5973         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5974         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5975         uint32_t ret_ref = 0;
5976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5979         ret_ref = (uintptr_t)ret_var.inner;
5980         if (ret_var.is_owned) {
5981                 ret_ref |= 1;
5982         }
5983         return ret_ref;
5984 }
5985
5986 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5987 CHECK(!owner->result_ok);
5988         return ParseOrSemanticError_clone(&*owner->contents.err);
5989 }
5990 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5991         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5992         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5993         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5994         uint32_t ret_ref = (uintptr_t)ret_copy;
5995         return ret_ref;
5996 }
5997
5998 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5999 CHECK(owner->result_ok);
6000         return SignedRawInvoice_clone(&*owner->contents.result);
6001 }
6002 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
6003         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6004         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
6005         uint32_t ret_ref = 0;
6006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6009         ret_ref = (uintptr_t)ret_var.inner;
6010         if (ret_var.is_owned) {
6011                 ret_ref |= 1;
6012         }
6013         return ret_ref;
6014 }
6015
6016 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6017 CHECK(!owner->result_ok);
6018         return ParseError_clone(&*owner->contents.err);
6019 }
6020 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
6021         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6022         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6023         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
6024         uint32_t ret_ref = (uintptr_t)ret_copy;
6025         return ret_ref;
6026 }
6027
6028 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6029         return RawInvoice_clone(&owner->a);
6030 }
6031 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
6032         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6033         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6034         uint32_t ret_ref = 0;
6035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6038         ret_ref = (uintptr_t)ret_var.inner;
6039         if (ret_var.is_owned) {
6040                 ret_ref |= 1;
6041         }
6042         return ret_ref;
6043 }
6044
6045 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6046         return ThirtyTwoBytes_clone(&owner->b);
6047 }
6048 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
6049         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6051         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
6052         return ret_arr;
6053 }
6054
6055 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6056         return InvoiceSignature_clone(&owner->c);
6057 }
6058 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
6059         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6060         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6061         uint32_t ret_ref = 0;
6062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6065         ret_ref = (uintptr_t)ret_var.inner;
6066         if (ret_var.is_owned) {
6067                 ret_ref |= 1;
6068         }
6069         return ret_ref;
6070 }
6071
6072 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6073 CHECK(owner->result_ok);
6074         return PayeePubKey_clone(&*owner->contents.result);
6075 }
6076 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
6077         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6078         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6079         uint32_t ret_ref = 0;
6080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6083         ret_ref = (uintptr_t)ret_var.inner;
6084         if (ret_var.is_owned) {
6085                 ret_ref |= 1;
6086         }
6087         return ret_ref;
6088 }
6089
6090 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6091 CHECK(!owner->result_ok);
6092         return *owner->contents.err;
6093 }
6094 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6095         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6096         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6097         return ret_conv;
6098 }
6099
6100 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6101         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6102         for (size_t i = 0; i < ret.datalen; i++) {
6103                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6104         }
6105         return ret;
6106 }
6107 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6108 CHECK(owner->result_ok);
6109         return PositiveTimestamp_clone(&*owner->contents.result);
6110 }
6111 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6112         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6113         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6114         uint32_t ret_ref = 0;
6115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6118         ret_ref = (uintptr_t)ret_var.inner;
6119         if (ret_var.is_owned) {
6120                 ret_ref |= 1;
6121         }
6122         return ret_ref;
6123 }
6124
6125 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6126 CHECK(!owner->result_ok);
6127         return CreationError_clone(&*owner->contents.err);
6128 }
6129 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6130         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6131         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6132         return ret_conv;
6133 }
6134
6135 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6136 CHECK(owner->result_ok);
6137         return *owner->contents.result;
6138 }
6139 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6140         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6141         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6142 }
6143
6144 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6145 CHECK(!owner->result_ok);
6146         return SemanticError_clone(&*owner->contents.err);
6147 }
6148 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6149         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6150         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6151         return ret_conv;
6152 }
6153
6154 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6155 CHECK(owner->result_ok);
6156         return Invoice_clone(&*owner->contents.result);
6157 }
6158 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6159         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6160         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6161         uint32_t ret_ref = 0;
6162         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6163         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6165         ret_ref = (uintptr_t)ret_var.inner;
6166         if (ret_var.is_owned) {
6167                 ret_ref |= 1;
6168         }
6169         return ret_ref;
6170 }
6171
6172 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6173 CHECK(!owner->result_ok);
6174         return SemanticError_clone(&*owner->contents.err);
6175 }
6176 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6177         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6178         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6179         return ret_conv;
6180 }
6181
6182 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6183 CHECK(owner->result_ok);
6184         return Description_clone(&*owner->contents.result);
6185 }
6186 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6187         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6188         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6189         uint32_t ret_ref = 0;
6190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6193         ret_ref = (uintptr_t)ret_var.inner;
6194         if (ret_var.is_owned) {
6195                 ret_ref |= 1;
6196         }
6197         return ret_ref;
6198 }
6199
6200 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6201 CHECK(!owner->result_ok);
6202         return CreationError_clone(&*owner->contents.err);
6203 }
6204 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6205         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6206         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6207         return ret_conv;
6208 }
6209
6210 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6211 CHECK(owner->result_ok);
6212         return PrivateRoute_clone(&*owner->contents.result);
6213 }
6214 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6215         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6216         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6217         uint32_t ret_ref = 0;
6218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6221         ret_ref = (uintptr_t)ret_var.inner;
6222         if (ret_var.is_owned) {
6223                 ret_ref |= 1;
6224         }
6225         return ret_ref;
6226 }
6227
6228 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6229 CHECK(!owner->result_ok);
6230         return CreationError_clone(&*owner->contents.err);
6231 }
6232 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6233         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6234         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6235         return ret_conv;
6236 }
6237
6238 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6239 CHECK(owner->result_ok);
6240         return *owner->contents.result;
6241 }
6242 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6243         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6244         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6245         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6246         return ret_conv;
6247 }
6248
6249 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6250 CHECK(!owner->result_ok);
6251         return *owner->contents.err;
6252 }
6253 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6254         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6255         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6256         return ret_conv;
6257 }
6258
6259 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6260 CHECK(owner->result_ok);
6261         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6262 }
6263 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6264         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6265         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6266         uint32_t ret_ref = 0;
6267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6270         ret_ref = (uintptr_t)ret_var.inner;
6271         if (ret_var.is_owned) {
6272                 ret_ref |= 1;
6273         }
6274         return ret_ref;
6275 }
6276
6277 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6278 CHECK(!owner->result_ok);
6279         return DecodeError_clone(&*owner->contents.err);
6280 }
6281 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6282         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6283         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6284         uint32_t ret_ref = 0;
6285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6288         ret_ref = (uintptr_t)ret_var.inner;
6289         if (ret_var.is_owned) {
6290                 ret_ref |= 1;
6291         }
6292         return ret_ref;
6293 }
6294
6295 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6296         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6297         switch(obj->tag) {
6298                 case LDKCOption_MonitorEventZ_Some: return 0;
6299                 case LDKCOption_MonitorEventZ_None: return 1;
6300                 default: abort();
6301         }
6302 }
6303 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6304         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6305         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6306                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6307         return some_ref;
6308 }
6309 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6310 CHECK(owner->result_ok);
6311         return COption_MonitorEventZ_clone(&*owner->contents.result);
6312 }
6313 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6314         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6315         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6316         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6317         uint32_t ret_ref = (uintptr_t)ret_copy;
6318         return ret_ref;
6319 }
6320
6321 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6322 CHECK(!owner->result_ok);
6323         return DecodeError_clone(&*owner->contents.err);
6324 }
6325 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6326         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6327         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6328         uint32_t ret_ref = 0;
6329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6332         ret_ref = (uintptr_t)ret_var.inner;
6333         if (ret_var.is_owned) {
6334                 ret_ref |= 1;
6335         }
6336         return ret_ref;
6337 }
6338
6339 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6340 CHECK(owner->result_ok);
6341         return HTLCUpdate_clone(&*owner->contents.result);
6342 }
6343 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6344         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6345         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6346         uint32_t ret_ref = 0;
6347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6350         ret_ref = (uintptr_t)ret_var.inner;
6351         if (ret_var.is_owned) {
6352                 ret_ref |= 1;
6353         }
6354         return ret_ref;
6355 }
6356
6357 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6358 CHECK(!owner->result_ok);
6359         return DecodeError_clone(&*owner->contents.err);
6360 }
6361 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6362         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6363         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6364         uint32_t ret_ref = 0;
6365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6368         ret_ref = (uintptr_t)ret_var.inner;
6369         if (ret_var.is_owned) {
6370                 ret_ref |= 1;
6371         }
6372         return ret_ref;
6373 }
6374
6375 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6376         return OutPoint_clone(&owner->a);
6377 }
6378 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6379         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6380         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6381         uint32_t ret_ref = 0;
6382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6385         ret_ref = (uintptr_t)ret_var.inner;
6386         if (ret_var.is_owned) {
6387                 ret_ref |= 1;
6388         }
6389         return ret_ref;
6390 }
6391
6392 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6393         return CVec_u8Z_clone(&owner->b);
6394 }
6395 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6396         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6397         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6398         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6399         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6400         CVec_u8Z_free(ret_var);
6401         return ret_arr;
6402 }
6403
6404 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6405         return owner->a;
6406 }
6407 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6408         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6409         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6410         return ret_conv;
6411 }
6412
6413 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6414         return CVec_u8Z_clone(&owner->b);
6415 }
6416 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6417         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6418         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6419         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6420         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6421         CVec_u8Z_free(ret_var);
6422         return ret_arr;
6423 }
6424
6425 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6426         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6427         for (size_t i = 0; i < ret.datalen; i++) {
6428                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6429         }
6430         return ret;
6431 }
6432 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6433         return ThirtyTwoBytes_clone(&owner->a);
6434 }
6435 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6436         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6437         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6438         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6439         return ret_arr;
6440 }
6441
6442 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6443         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6444 }
6445 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6446         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6447         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6448         uint32_tArray ret_arr = NULL;
6449         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6450         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6451         for (size_t v = 0; v < ret_var.datalen; v++) {
6452                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6453                 *ret_conv_21_conv = ret_var.data[v];
6454                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6455         }
6456         
6457         FREE(ret_var.data);
6458         return ret_arr;
6459 }
6460
6461 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6462         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 };
6463         for (size_t i = 0; i < ret.datalen; i++) {
6464                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6465         }
6466         return ret;
6467 }
6468 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6469         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6470         for (size_t i = 0; i < ret.datalen; i++) {
6471                 ret.data[i] = Event_clone(&orig->data[i]);
6472         }
6473         return ret;
6474 }
6475 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6476         return owner->a;
6477 }
6478 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6479         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6480         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6481         return ret_conv;
6482 }
6483
6484 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6485         return TxOut_clone(&owner->b);
6486 }
6487 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6488         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6489         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6490         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6491         return (uint32_t)ret_ref;
6492 }
6493
6494 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6495         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6496         for (size_t i = 0; i < ret.datalen; i++) {
6497                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6498         }
6499         return ret;
6500 }
6501 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6502         return ThirtyTwoBytes_clone(&owner->a);
6503 }
6504 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6505         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6506         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6507         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6508         return ret_arr;
6509 }
6510
6511 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6512         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6513 }
6514 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6515         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6516         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6517         uint32_tArray ret_arr = NULL;
6518         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6519         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6520         for (size_t u = 0; u < ret_var.datalen; u++) {
6521                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6522                 *ret_conv_20_conv = ret_var.data[u];
6523                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6524         }
6525         
6526         FREE(ret_var.data);
6527         return ret_arr;
6528 }
6529
6530 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6531         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 };
6532         for (size_t i = 0; i < ret.datalen; i++) {
6533                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6534         }
6535         return ret;
6536 }
6537 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6538         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6539         switch(obj->tag) {
6540                 case LDKBalance_ClaimableOnChannelClose: return 0;
6541                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6542                 case LDKBalance_ContentiousClaimable: return 2;
6543                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6544                 default: abort();
6545         }
6546 }
6547 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6548         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6549         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6550                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6551         return claimable_amount_satoshis_conv;
6552 }
6553 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6554         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6555         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6556                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6557         return claimable_amount_satoshis_conv;
6558 }
6559 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6560         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6561         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6562                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6563         return confirmation_height_conv;
6564 }
6565 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6566         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6567         assert(obj->tag == LDKBalance_ContentiousClaimable);
6568                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6569         return claimable_amount_satoshis_conv;
6570 }
6571 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6572         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6573         assert(obj->tag == LDKBalance_ContentiousClaimable);
6574                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6575         return timeout_height_conv;
6576 }
6577 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6578         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6579         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6580                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6581         return claimable_amount_satoshis_conv;
6582 }
6583 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6584         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6585         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6586                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6587         return claimable_height_conv;
6588 }
6589 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6590         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6591         for (size_t i = 0; i < ret.datalen; i++) {
6592                 ret.data[i] = Balance_clone(&orig->data[i]);
6593         }
6594         return ret;
6595 }
6596 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6597         return ThirtyTwoBytes_clone(&owner->a);
6598 }
6599 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6600         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6601         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6602         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6603         return ret_arr;
6604 }
6605
6606 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6607         return ChannelMonitor_clone(&owner->b);
6608 }
6609 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6610         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6611         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6612         uint32_t ret_ref = 0;
6613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6616         ret_ref = (uintptr_t)ret_var.inner;
6617         if (ret_var.is_owned) {
6618                 ret_ref |= 1;
6619         }
6620         return ret_ref;
6621 }
6622
6623 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6624 CHECK(owner->result_ok);
6625         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6626 }
6627 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6628         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6629         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6630         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6631         return ((uint32_t)ret_conv);
6632 }
6633
6634 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6635 CHECK(!owner->result_ok);
6636         return DecodeError_clone(&*owner->contents.err);
6637 }
6638 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6639         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6640         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6641         uint32_t ret_ref = 0;
6642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6645         ret_ref = (uintptr_t)ret_var.inner;
6646         if (ret_var.is_owned) {
6647                 ret_ref |= 1;
6648         }
6649         return ret_ref;
6650 }
6651
6652 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6653         return owner->a;
6654 }
6655 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6656         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6657         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6658         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6659         return ret_arr;
6660 }
6661
6662 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6663         return Type_clone(&owner->b);
6664 }
6665 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6666         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6667         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6668         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6669         return (uint32_t)ret_ret;
6670 }
6671
6672 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6673         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6674         for (size_t i = 0; i < ret.datalen; i++) {
6675                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6676         }
6677         return ret;
6678 }
6679 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6680         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6681         switch(obj->tag) {
6682                 case LDKCOption_NetAddressZ_Some: return 0;
6683                 case LDKCOption_NetAddressZ_None: return 1;
6684                 default: abort();
6685         }
6686 }
6687 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6688         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6689         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6690                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6691         return some_ref;
6692 }
6693 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6694 CHECK(owner->result_ok);
6695         return CVec_u8Z_clone(&*owner->contents.result);
6696 }
6697 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6698         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6699         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6700         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6701         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6702         CVec_u8Z_free(ret_var);
6703         return ret_arr;
6704 }
6705
6706 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6707 CHECK(!owner->result_ok);
6708         return PeerHandleError_clone(&*owner->contents.err);
6709 }
6710 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6711         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6712         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6713         uint32_t ret_ref = 0;
6714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6717         ret_ref = (uintptr_t)ret_var.inner;
6718         if (ret_var.is_owned) {
6719                 ret_ref |= 1;
6720         }
6721         return ret_ref;
6722 }
6723
6724 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6725 CHECK(owner->result_ok);
6726         return *owner->contents.result;
6727 }
6728 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6729         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6730         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6731 }
6732
6733 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6734 CHECK(!owner->result_ok);
6735         return PeerHandleError_clone(&*owner->contents.err);
6736 }
6737 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6738         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6739         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6740         uint32_t ret_ref = 0;
6741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6744         ret_ref = (uintptr_t)ret_var.inner;
6745         if (ret_var.is_owned) {
6746                 ret_ref |= 1;
6747         }
6748         return ret_ref;
6749 }
6750
6751 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6752 CHECK(owner->result_ok);
6753         return *owner->contents.result;
6754 }
6755 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6756         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6757         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6758         return ret_conv;
6759 }
6760
6761 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6762 CHECK(!owner->result_ok);
6763         return PeerHandleError_clone(&*owner->contents.err);
6764 }
6765 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6766         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6767         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6768         uint32_t ret_ref = 0;
6769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6772         ret_ref = (uintptr_t)ret_var.inner;
6773         if (ret_var.is_owned) {
6774                 ret_ref |= 1;
6775         }
6776         return ret_ref;
6777 }
6778
6779 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6780 CHECK(owner->result_ok);
6781         return *owner->contents.result;
6782 }
6783 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6784         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6785         CResult_NoneErrorZ_get_ok(owner_conv);
6786 }
6787
6788 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6789 CHECK(!owner->result_ok);
6790         return *owner->contents.err;
6791 }
6792 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6793         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6794         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6795         return ret_conv;
6796 }
6797
6798 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6799 CHECK(owner->result_ok);
6800         return NetAddress_clone(&*owner->contents.result);
6801 }
6802 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6803         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6804         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6805         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6806         uint32_t ret_ref = (uintptr_t)ret_copy;
6807         return ret_ref;
6808 }
6809
6810 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6811 CHECK(!owner->result_ok);
6812         return DecodeError_clone(&*owner->contents.err);
6813 }
6814 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6815         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6816         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6817         uint32_t ret_ref = 0;
6818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6821         ret_ref = (uintptr_t)ret_var.inner;
6822         if (ret_var.is_owned) {
6823                 ret_ref |= 1;
6824         }
6825         return ret_ref;
6826 }
6827
6828 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6829         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6830         for (size_t i = 0; i < ret.datalen; i++) {
6831                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6832         }
6833         return ret;
6834 }
6835 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6836         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6837         for (size_t i = 0; i < ret.datalen; i++) {
6838                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6839         }
6840         return ret;
6841 }
6842 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6843         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6844         for (size_t i = 0; i < ret.datalen; i++) {
6845                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6846         }
6847         return ret;
6848 }
6849 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6850         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6851         for (size_t i = 0; i < ret.datalen; i++) {
6852                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6853         }
6854         return ret;
6855 }
6856 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6857 CHECK(owner->result_ok);
6858         return AcceptChannel_clone(&*owner->contents.result);
6859 }
6860 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6861         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6862         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6863         uint32_t ret_ref = 0;
6864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6867         ret_ref = (uintptr_t)ret_var.inner;
6868         if (ret_var.is_owned) {
6869                 ret_ref |= 1;
6870         }
6871         return ret_ref;
6872 }
6873
6874 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6875 CHECK(!owner->result_ok);
6876         return DecodeError_clone(&*owner->contents.err);
6877 }
6878 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6879         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6880         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6881         uint32_t ret_ref = 0;
6882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6885         ret_ref = (uintptr_t)ret_var.inner;
6886         if (ret_var.is_owned) {
6887                 ret_ref |= 1;
6888         }
6889         return ret_ref;
6890 }
6891
6892 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6893 CHECK(owner->result_ok);
6894         return AnnouncementSignatures_clone(&*owner->contents.result);
6895 }
6896 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6897         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6898         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6899         uint32_t ret_ref = 0;
6900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6903         ret_ref = (uintptr_t)ret_var.inner;
6904         if (ret_var.is_owned) {
6905                 ret_ref |= 1;
6906         }
6907         return ret_ref;
6908 }
6909
6910 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6911 CHECK(!owner->result_ok);
6912         return DecodeError_clone(&*owner->contents.err);
6913 }
6914 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6915         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6916         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6917         uint32_t ret_ref = 0;
6918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6921         ret_ref = (uintptr_t)ret_var.inner;
6922         if (ret_var.is_owned) {
6923                 ret_ref |= 1;
6924         }
6925         return ret_ref;
6926 }
6927
6928 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6929 CHECK(owner->result_ok);
6930         return ChannelReestablish_clone(&*owner->contents.result);
6931 }
6932 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6933         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6934         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6935         uint32_t ret_ref = 0;
6936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6939         ret_ref = (uintptr_t)ret_var.inner;
6940         if (ret_var.is_owned) {
6941                 ret_ref |= 1;
6942         }
6943         return ret_ref;
6944 }
6945
6946 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6947 CHECK(!owner->result_ok);
6948         return DecodeError_clone(&*owner->contents.err);
6949 }
6950 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6951         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6952         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6953         uint32_t ret_ref = 0;
6954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6957         ret_ref = (uintptr_t)ret_var.inner;
6958         if (ret_var.is_owned) {
6959                 ret_ref |= 1;
6960         }
6961         return ret_ref;
6962 }
6963
6964 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6965 CHECK(owner->result_ok);
6966         return ClosingSigned_clone(&*owner->contents.result);
6967 }
6968 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6969         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6970         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6971         uint32_t ret_ref = 0;
6972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6975         ret_ref = (uintptr_t)ret_var.inner;
6976         if (ret_var.is_owned) {
6977                 ret_ref |= 1;
6978         }
6979         return ret_ref;
6980 }
6981
6982 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6983 CHECK(!owner->result_ok);
6984         return DecodeError_clone(&*owner->contents.err);
6985 }
6986 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6987         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6988         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6989         uint32_t ret_ref = 0;
6990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6993         ret_ref = (uintptr_t)ret_var.inner;
6994         if (ret_var.is_owned) {
6995                 ret_ref |= 1;
6996         }
6997         return ret_ref;
6998 }
6999
7000 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7001 CHECK(owner->result_ok);
7002         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7003 }
7004 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
7005         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7006         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7007         uint32_t ret_ref = 0;
7008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7011         ret_ref = (uintptr_t)ret_var.inner;
7012         if (ret_var.is_owned) {
7013                 ret_ref |= 1;
7014         }
7015         return ret_ref;
7016 }
7017
7018 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7019 CHECK(!owner->result_ok);
7020         return DecodeError_clone(&*owner->contents.err);
7021 }
7022 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
7023         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7024         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7025         uint32_t ret_ref = 0;
7026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7029         ret_ref = (uintptr_t)ret_var.inner;
7030         if (ret_var.is_owned) {
7031                 ret_ref |= 1;
7032         }
7033         return ret_ref;
7034 }
7035
7036 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7037 CHECK(owner->result_ok);
7038         return CommitmentSigned_clone(&*owner->contents.result);
7039 }
7040 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
7041         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7042         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7043         uint32_t ret_ref = 0;
7044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7047         ret_ref = (uintptr_t)ret_var.inner;
7048         if (ret_var.is_owned) {
7049                 ret_ref |= 1;
7050         }
7051         return ret_ref;
7052 }
7053
7054 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7055 CHECK(!owner->result_ok);
7056         return DecodeError_clone(&*owner->contents.err);
7057 }
7058 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
7059         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7060         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7061         uint32_t ret_ref = 0;
7062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7065         ret_ref = (uintptr_t)ret_var.inner;
7066         if (ret_var.is_owned) {
7067                 ret_ref |= 1;
7068         }
7069         return ret_ref;
7070 }
7071
7072 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7073 CHECK(owner->result_ok);
7074         return FundingCreated_clone(&*owner->contents.result);
7075 }
7076 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
7077         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7078         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7079         uint32_t ret_ref = 0;
7080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7083         ret_ref = (uintptr_t)ret_var.inner;
7084         if (ret_var.is_owned) {
7085                 ret_ref |= 1;
7086         }
7087         return ret_ref;
7088 }
7089
7090 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7091 CHECK(!owner->result_ok);
7092         return DecodeError_clone(&*owner->contents.err);
7093 }
7094 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7095         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7096         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7097         uint32_t ret_ref = 0;
7098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7101         ret_ref = (uintptr_t)ret_var.inner;
7102         if (ret_var.is_owned) {
7103                 ret_ref |= 1;
7104         }
7105         return ret_ref;
7106 }
7107
7108 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7109 CHECK(owner->result_ok);
7110         return FundingSigned_clone(&*owner->contents.result);
7111 }
7112 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7113         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7114         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7115         uint32_t ret_ref = 0;
7116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7119         ret_ref = (uintptr_t)ret_var.inner;
7120         if (ret_var.is_owned) {
7121                 ret_ref |= 1;
7122         }
7123         return ret_ref;
7124 }
7125
7126 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7127 CHECK(!owner->result_ok);
7128         return DecodeError_clone(&*owner->contents.err);
7129 }
7130 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7131         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7132         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7133         uint32_t ret_ref = 0;
7134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7137         ret_ref = (uintptr_t)ret_var.inner;
7138         if (ret_var.is_owned) {
7139                 ret_ref |= 1;
7140         }
7141         return ret_ref;
7142 }
7143
7144 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7145 CHECK(owner->result_ok);
7146         return ChannelReady_clone(&*owner->contents.result);
7147 }
7148 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7149         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7150         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
7151         uint32_t ret_ref = 0;
7152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7155         ret_ref = (uintptr_t)ret_var.inner;
7156         if (ret_var.is_owned) {
7157                 ret_ref |= 1;
7158         }
7159         return ret_ref;
7160 }
7161
7162 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7163 CHECK(!owner->result_ok);
7164         return DecodeError_clone(&*owner->contents.err);
7165 }
7166 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7167         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7168         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
7169         uint32_t ret_ref = 0;
7170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7173         ret_ref = (uintptr_t)ret_var.inner;
7174         if (ret_var.is_owned) {
7175                 ret_ref |= 1;
7176         }
7177         return ret_ref;
7178 }
7179
7180 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7181 CHECK(owner->result_ok);
7182         return Init_clone(&*owner->contents.result);
7183 }
7184 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7185         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7186         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7187         uint32_t ret_ref = 0;
7188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7191         ret_ref = (uintptr_t)ret_var.inner;
7192         if (ret_var.is_owned) {
7193                 ret_ref |= 1;
7194         }
7195         return ret_ref;
7196 }
7197
7198 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7199 CHECK(!owner->result_ok);
7200         return DecodeError_clone(&*owner->contents.err);
7201 }
7202 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7203         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7204         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7205         uint32_t ret_ref = 0;
7206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7209         ret_ref = (uintptr_t)ret_var.inner;
7210         if (ret_var.is_owned) {
7211                 ret_ref |= 1;
7212         }
7213         return ret_ref;
7214 }
7215
7216 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7217 CHECK(owner->result_ok);
7218         return OpenChannel_clone(&*owner->contents.result);
7219 }
7220 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7221         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7222         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7223         uint32_t ret_ref = 0;
7224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7227         ret_ref = (uintptr_t)ret_var.inner;
7228         if (ret_var.is_owned) {
7229                 ret_ref |= 1;
7230         }
7231         return ret_ref;
7232 }
7233
7234 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7235 CHECK(!owner->result_ok);
7236         return DecodeError_clone(&*owner->contents.err);
7237 }
7238 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7239         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7240         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7241         uint32_t ret_ref = 0;
7242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7245         ret_ref = (uintptr_t)ret_var.inner;
7246         if (ret_var.is_owned) {
7247                 ret_ref |= 1;
7248         }
7249         return ret_ref;
7250 }
7251
7252 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7253 CHECK(owner->result_ok);
7254         return RevokeAndACK_clone(&*owner->contents.result);
7255 }
7256 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7257         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7258         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7259         uint32_t ret_ref = 0;
7260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7263         ret_ref = (uintptr_t)ret_var.inner;
7264         if (ret_var.is_owned) {
7265                 ret_ref |= 1;
7266         }
7267         return ret_ref;
7268 }
7269
7270 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7271 CHECK(!owner->result_ok);
7272         return DecodeError_clone(&*owner->contents.err);
7273 }
7274 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7275         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7276         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7277         uint32_t ret_ref = 0;
7278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7281         ret_ref = (uintptr_t)ret_var.inner;
7282         if (ret_var.is_owned) {
7283                 ret_ref |= 1;
7284         }
7285         return ret_ref;
7286 }
7287
7288 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7289 CHECK(owner->result_ok);
7290         return Shutdown_clone(&*owner->contents.result);
7291 }
7292 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7293         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7294         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7295         uint32_t ret_ref = 0;
7296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7299         ret_ref = (uintptr_t)ret_var.inner;
7300         if (ret_var.is_owned) {
7301                 ret_ref |= 1;
7302         }
7303         return ret_ref;
7304 }
7305
7306 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(!owner->result_ok);
7308         return DecodeError_clone(&*owner->contents.err);
7309 }
7310 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7311         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7312         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7313         uint32_t ret_ref = 0;
7314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7317         ret_ref = (uintptr_t)ret_var.inner;
7318         if (ret_var.is_owned) {
7319                 ret_ref |= 1;
7320         }
7321         return ret_ref;
7322 }
7323
7324 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7325 CHECK(owner->result_ok);
7326         return UpdateFailHTLC_clone(&*owner->contents.result);
7327 }
7328 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7329         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7330         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7331         uint32_t ret_ref = 0;
7332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7335         ret_ref = (uintptr_t)ret_var.inner;
7336         if (ret_var.is_owned) {
7337                 ret_ref |= 1;
7338         }
7339         return ret_ref;
7340 }
7341
7342 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7343 CHECK(!owner->result_ok);
7344         return DecodeError_clone(&*owner->contents.err);
7345 }
7346 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7347         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7348         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7349         uint32_t ret_ref = 0;
7350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7353         ret_ref = (uintptr_t)ret_var.inner;
7354         if (ret_var.is_owned) {
7355                 ret_ref |= 1;
7356         }
7357         return ret_ref;
7358 }
7359
7360 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7361 CHECK(owner->result_ok);
7362         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7363 }
7364 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7365         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7366         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7367         uint32_t ret_ref = 0;
7368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7371         ret_ref = (uintptr_t)ret_var.inner;
7372         if (ret_var.is_owned) {
7373                 ret_ref |= 1;
7374         }
7375         return ret_ref;
7376 }
7377
7378 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7379 CHECK(!owner->result_ok);
7380         return DecodeError_clone(&*owner->contents.err);
7381 }
7382 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7383         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7384         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7385         uint32_t ret_ref = 0;
7386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7389         ret_ref = (uintptr_t)ret_var.inner;
7390         if (ret_var.is_owned) {
7391                 ret_ref |= 1;
7392         }
7393         return ret_ref;
7394 }
7395
7396 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7397 CHECK(owner->result_ok);
7398         return UpdateFee_clone(&*owner->contents.result);
7399 }
7400 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7401         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7402         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7403         uint32_t ret_ref = 0;
7404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7407         ret_ref = (uintptr_t)ret_var.inner;
7408         if (ret_var.is_owned) {
7409                 ret_ref |= 1;
7410         }
7411         return ret_ref;
7412 }
7413
7414 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7415 CHECK(!owner->result_ok);
7416         return DecodeError_clone(&*owner->contents.err);
7417 }
7418 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7419         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7420         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7421         uint32_t ret_ref = 0;
7422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7425         ret_ref = (uintptr_t)ret_var.inner;
7426         if (ret_var.is_owned) {
7427                 ret_ref |= 1;
7428         }
7429         return ret_ref;
7430 }
7431
7432 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7433 CHECK(owner->result_ok);
7434         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7435 }
7436 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7437         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7438         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7439         uint32_t ret_ref = 0;
7440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7443         ret_ref = (uintptr_t)ret_var.inner;
7444         if (ret_var.is_owned) {
7445                 ret_ref |= 1;
7446         }
7447         return ret_ref;
7448 }
7449
7450 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7451 CHECK(!owner->result_ok);
7452         return DecodeError_clone(&*owner->contents.err);
7453 }
7454 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7455         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7456         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7457         uint32_t ret_ref = 0;
7458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7461         ret_ref = (uintptr_t)ret_var.inner;
7462         if (ret_var.is_owned) {
7463                 ret_ref |= 1;
7464         }
7465         return ret_ref;
7466 }
7467
7468 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7469 CHECK(owner->result_ok);
7470         return UpdateAddHTLC_clone(&*owner->contents.result);
7471 }
7472 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7473         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7474         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7475         uint32_t ret_ref = 0;
7476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7479         ret_ref = (uintptr_t)ret_var.inner;
7480         if (ret_var.is_owned) {
7481                 ret_ref |= 1;
7482         }
7483         return ret_ref;
7484 }
7485
7486 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7487 CHECK(!owner->result_ok);
7488         return DecodeError_clone(&*owner->contents.err);
7489 }
7490 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7491         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7492         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7493         uint32_t ret_ref = 0;
7494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7497         ret_ref = (uintptr_t)ret_var.inner;
7498         if (ret_var.is_owned) {
7499                 ret_ref |= 1;
7500         }
7501         return ret_ref;
7502 }
7503
7504 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7505 CHECK(owner->result_ok);
7506         return Ping_clone(&*owner->contents.result);
7507 }
7508 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7509         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7510         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7511         uint32_t ret_ref = 0;
7512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7515         ret_ref = (uintptr_t)ret_var.inner;
7516         if (ret_var.is_owned) {
7517                 ret_ref |= 1;
7518         }
7519         return ret_ref;
7520 }
7521
7522 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7523 CHECK(!owner->result_ok);
7524         return DecodeError_clone(&*owner->contents.err);
7525 }
7526 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7527         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7528         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7529         uint32_t ret_ref = 0;
7530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7533         ret_ref = (uintptr_t)ret_var.inner;
7534         if (ret_var.is_owned) {
7535                 ret_ref |= 1;
7536         }
7537         return ret_ref;
7538 }
7539
7540 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7541 CHECK(owner->result_ok);
7542         return Pong_clone(&*owner->contents.result);
7543 }
7544 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7545         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7546         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7547         uint32_t ret_ref = 0;
7548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7551         ret_ref = (uintptr_t)ret_var.inner;
7552         if (ret_var.is_owned) {
7553                 ret_ref |= 1;
7554         }
7555         return ret_ref;
7556 }
7557
7558 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7559 CHECK(!owner->result_ok);
7560         return DecodeError_clone(&*owner->contents.err);
7561 }
7562 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7563         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7564         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7565         uint32_t ret_ref = 0;
7566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7569         ret_ref = (uintptr_t)ret_var.inner;
7570         if (ret_var.is_owned) {
7571                 ret_ref |= 1;
7572         }
7573         return ret_ref;
7574 }
7575
7576 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7577 CHECK(owner->result_ok);
7578         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7579 }
7580 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7581         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7582         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7583         uint32_t ret_ref = 0;
7584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7587         ret_ref = (uintptr_t)ret_var.inner;
7588         if (ret_var.is_owned) {
7589                 ret_ref |= 1;
7590         }
7591         return ret_ref;
7592 }
7593
7594 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7595 CHECK(!owner->result_ok);
7596         return DecodeError_clone(&*owner->contents.err);
7597 }
7598 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7599         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7600         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7601         uint32_t ret_ref = 0;
7602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7605         ret_ref = (uintptr_t)ret_var.inner;
7606         if (ret_var.is_owned) {
7607                 ret_ref |= 1;
7608         }
7609         return ret_ref;
7610 }
7611
7612 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7613 CHECK(owner->result_ok);
7614         return ChannelAnnouncement_clone(&*owner->contents.result);
7615 }
7616 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7617         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7618         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7619         uint32_t ret_ref = 0;
7620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7623         ret_ref = (uintptr_t)ret_var.inner;
7624         if (ret_var.is_owned) {
7625                 ret_ref |= 1;
7626         }
7627         return ret_ref;
7628 }
7629
7630 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7631 CHECK(!owner->result_ok);
7632         return DecodeError_clone(&*owner->contents.err);
7633 }
7634 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7635         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7636         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7637         uint32_t ret_ref = 0;
7638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7641         ret_ref = (uintptr_t)ret_var.inner;
7642         if (ret_var.is_owned) {
7643                 ret_ref |= 1;
7644         }
7645         return ret_ref;
7646 }
7647
7648 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7649 CHECK(owner->result_ok);
7650         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7651 }
7652 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7653         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7654         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7655         uint32_t ret_ref = 0;
7656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7659         ret_ref = (uintptr_t)ret_var.inner;
7660         if (ret_var.is_owned) {
7661                 ret_ref |= 1;
7662         }
7663         return ret_ref;
7664 }
7665
7666 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7667 CHECK(!owner->result_ok);
7668         return DecodeError_clone(&*owner->contents.err);
7669 }
7670 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7671         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7672         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7673         uint32_t ret_ref = 0;
7674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7677         ret_ref = (uintptr_t)ret_var.inner;
7678         if (ret_var.is_owned) {
7679                 ret_ref |= 1;
7680         }
7681         return ret_ref;
7682 }
7683
7684 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7685 CHECK(owner->result_ok);
7686         return ChannelUpdate_clone(&*owner->contents.result);
7687 }
7688 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7689         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7690         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7691         uint32_t ret_ref = 0;
7692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7695         ret_ref = (uintptr_t)ret_var.inner;
7696         if (ret_var.is_owned) {
7697                 ret_ref |= 1;
7698         }
7699         return ret_ref;
7700 }
7701
7702 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7703 CHECK(!owner->result_ok);
7704         return DecodeError_clone(&*owner->contents.err);
7705 }
7706 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7707         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7708         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7709         uint32_t ret_ref = 0;
7710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7713         ret_ref = (uintptr_t)ret_var.inner;
7714         if (ret_var.is_owned) {
7715                 ret_ref |= 1;
7716         }
7717         return ret_ref;
7718 }
7719
7720 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7721 CHECK(owner->result_ok);
7722         return ErrorMessage_clone(&*owner->contents.result);
7723 }
7724 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7725         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7726         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7727         uint32_t ret_ref = 0;
7728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7731         ret_ref = (uintptr_t)ret_var.inner;
7732         if (ret_var.is_owned) {
7733                 ret_ref |= 1;
7734         }
7735         return ret_ref;
7736 }
7737
7738 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7739 CHECK(!owner->result_ok);
7740         return DecodeError_clone(&*owner->contents.err);
7741 }
7742 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7743         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7744         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7745         uint32_t ret_ref = 0;
7746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7749         ret_ref = (uintptr_t)ret_var.inner;
7750         if (ret_var.is_owned) {
7751                 ret_ref |= 1;
7752         }
7753         return ret_ref;
7754 }
7755
7756 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7757 CHECK(owner->result_ok);
7758         return WarningMessage_clone(&*owner->contents.result);
7759 }
7760 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7761         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7762         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7763         uint32_t ret_ref = 0;
7764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7767         ret_ref = (uintptr_t)ret_var.inner;
7768         if (ret_var.is_owned) {
7769                 ret_ref |= 1;
7770         }
7771         return ret_ref;
7772 }
7773
7774 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7775 CHECK(!owner->result_ok);
7776         return DecodeError_clone(&*owner->contents.err);
7777 }
7778 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7779         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7780         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7781         uint32_t ret_ref = 0;
7782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7785         ret_ref = (uintptr_t)ret_var.inner;
7786         if (ret_var.is_owned) {
7787                 ret_ref |= 1;
7788         }
7789         return ret_ref;
7790 }
7791
7792 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7793 CHECK(owner->result_ok);
7794         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7795 }
7796 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7797         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7798         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7799         uint32_t ret_ref = 0;
7800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7803         ret_ref = (uintptr_t)ret_var.inner;
7804         if (ret_var.is_owned) {
7805                 ret_ref |= 1;
7806         }
7807         return ret_ref;
7808 }
7809
7810 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7811 CHECK(!owner->result_ok);
7812         return DecodeError_clone(&*owner->contents.err);
7813 }
7814 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7815         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7816         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7817         uint32_t ret_ref = 0;
7818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7821         ret_ref = (uintptr_t)ret_var.inner;
7822         if (ret_var.is_owned) {
7823                 ret_ref |= 1;
7824         }
7825         return ret_ref;
7826 }
7827
7828 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7829 CHECK(owner->result_ok);
7830         return NodeAnnouncement_clone(&*owner->contents.result);
7831 }
7832 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7833         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7834         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7835         uint32_t ret_ref = 0;
7836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7839         ret_ref = (uintptr_t)ret_var.inner;
7840         if (ret_var.is_owned) {
7841                 ret_ref |= 1;
7842         }
7843         return ret_ref;
7844 }
7845
7846 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7847 CHECK(!owner->result_ok);
7848         return DecodeError_clone(&*owner->contents.err);
7849 }
7850 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7851         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7852         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7853         uint32_t ret_ref = 0;
7854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7857         ret_ref = (uintptr_t)ret_var.inner;
7858         if (ret_var.is_owned) {
7859                 ret_ref |= 1;
7860         }
7861         return ret_ref;
7862 }
7863
7864 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7865 CHECK(owner->result_ok);
7866         return QueryShortChannelIds_clone(&*owner->contents.result);
7867 }
7868 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7869         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7870         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7871         uint32_t ret_ref = 0;
7872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7875         ret_ref = (uintptr_t)ret_var.inner;
7876         if (ret_var.is_owned) {
7877                 ret_ref |= 1;
7878         }
7879         return ret_ref;
7880 }
7881
7882 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7883 CHECK(!owner->result_ok);
7884         return DecodeError_clone(&*owner->contents.err);
7885 }
7886 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7887         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7888         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7889         uint32_t ret_ref = 0;
7890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7893         ret_ref = (uintptr_t)ret_var.inner;
7894         if (ret_var.is_owned) {
7895                 ret_ref |= 1;
7896         }
7897         return ret_ref;
7898 }
7899
7900 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7901 CHECK(owner->result_ok);
7902         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7903 }
7904 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7905         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7906         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7907         uint32_t ret_ref = 0;
7908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7911         ret_ref = (uintptr_t)ret_var.inner;
7912         if (ret_var.is_owned) {
7913                 ret_ref |= 1;
7914         }
7915         return ret_ref;
7916 }
7917
7918 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7919 CHECK(!owner->result_ok);
7920         return DecodeError_clone(&*owner->contents.err);
7921 }
7922 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7923         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7924         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7925         uint32_t ret_ref = 0;
7926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7929         ret_ref = (uintptr_t)ret_var.inner;
7930         if (ret_var.is_owned) {
7931                 ret_ref |= 1;
7932         }
7933         return ret_ref;
7934 }
7935
7936 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7937 CHECK(owner->result_ok);
7938         return QueryChannelRange_clone(&*owner->contents.result);
7939 }
7940 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7941         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7942         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7943         uint32_t ret_ref = 0;
7944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7947         ret_ref = (uintptr_t)ret_var.inner;
7948         if (ret_var.is_owned) {
7949                 ret_ref |= 1;
7950         }
7951         return ret_ref;
7952 }
7953
7954 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7955 CHECK(!owner->result_ok);
7956         return DecodeError_clone(&*owner->contents.err);
7957 }
7958 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7959         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7960         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7961         uint32_t ret_ref = 0;
7962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7965         ret_ref = (uintptr_t)ret_var.inner;
7966         if (ret_var.is_owned) {
7967                 ret_ref |= 1;
7968         }
7969         return ret_ref;
7970 }
7971
7972 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7973 CHECK(owner->result_ok);
7974         return ReplyChannelRange_clone(&*owner->contents.result);
7975 }
7976 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7977         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7978         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7979         uint32_t ret_ref = 0;
7980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7983         ret_ref = (uintptr_t)ret_var.inner;
7984         if (ret_var.is_owned) {
7985                 ret_ref |= 1;
7986         }
7987         return ret_ref;
7988 }
7989
7990 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7991 CHECK(!owner->result_ok);
7992         return DecodeError_clone(&*owner->contents.err);
7993 }
7994 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7995         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7996         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7997         uint32_t ret_ref = 0;
7998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8001         ret_ref = (uintptr_t)ret_var.inner;
8002         if (ret_var.is_owned) {
8003                 ret_ref |= 1;
8004         }
8005         return ret_ref;
8006 }
8007
8008 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8009 CHECK(owner->result_ok);
8010         return GossipTimestampFilter_clone(&*owner->contents.result);
8011 }
8012 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
8013         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8014         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8015         uint32_t ret_ref = 0;
8016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8019         ret_ref = (uintptr_t)ret_var.inner;
8020         if (ret_var.is_owned) {
8021                 ret_ref |= 1;
8022         }
8023         return ret_ref;
8024 }
8025
8026 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8027 CHECK(!owner->result_ok);
8028         return DecodeError_clone(&*owner->contents.err);
8029 }
8030 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
8031         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8032         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8033         uint32_t ret_ref = 0;
8034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8037         ret_ref = (uintptr_t)ret_var.inner;
8038         if (ret_var.is_owned) {
8039                 ret_ref |= 1;
8040         }
8041         return ret_ref;
8042 }
8043
8044 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
8045         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8046         switch(obj->tag) {
8047                 case LDKSignOrCreationError_SignError: return 0;
8048                 case LDKSignOrCreationError_CreationError: return 1;
8049                 default: abort();
8050         }
8051 }
8052 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
8053         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8054         assert(obj->tag == LDKSignOrCreationError_CreationError);
8055                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
8056         return creation_error_conv;
8057 }
8058 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8059 CHECK(owner->result_ok);
8060         return Invoice_clone(&*owner->contents.result);
8061 }
8062 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
8063         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8064         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8065         uint32_t ret_ref = 0;
8066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8069         ret_ref = (uintptr_t)ret_var.inner;
8070         if (ret_var.is_owned) {
8071                 ret_ref |= 1;
8072         }
8073         return ret_ref;
8074 }
8075
8076 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8077 CHECK(!owner->result_ok);
8078         return SignOrCreationError_clone(&*owner->contents.err);
8079 }
8080 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
8081         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8082         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8083         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8084         uint32_t ret_ref = (uintptr_t)ret_copy;
8085         return ret_ref;
8086 }
8087
8088 typedef struct LDKFilter_JCalls {
8089         atomic_size_t refcnt;
8090         uint32_t instance_ptr;
8091 } LDKFilter_JCalls;
8092 static void LDKFilter_JCalls_free(void* this_arg) {
8093         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8094         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8095                 FREE(j_calls);
8096         }
8097 }
8098 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8099         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8100         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8101         memcpy(txid_arr->elems, *txid, 32);
8102         LDKu8slice script_pubkey_var = script_pubkey;
8103         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8104         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8105         js_invoke_function_u_uu(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
8106 }
8107 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8108         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8109         LDKWatchedOutput output_var = output;
8110         uint32_t output_ref = 0;
8111         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8112         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8113         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8114         output_ref = (uintptr_t)output_var.inner;
8115         if (output_var.is_owned) {
8116                 output_ref |= 1;
8117         }
8118         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 33, (uint32_t)output_ref);
8119         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8120         CHECK_ACCESS(ret_ptr);
8121         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8122         FREE((void*)ret);
8123         return ret_conv;
8124 }
8125 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8126         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8127         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8128 }
8129 static inline LDKFilter LDKFilter_init (JSValue o) {
8130         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8131         atomic_init(&calls->refcnt, 1);
8132         calls->instance_ptr = o;
8133
8134         LDKFilter ret = {
8135                 .this_arg = (void*) calls,
8136                 .register_tx = register_tx_LDKFilter_jcall,
8137                 .register_output = register_output_LDKFilter_jcall,
8138                 .free = LDKFilter_JCalls_free,
8139         };
8140         return ret;
8141 }
8142 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8143         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8144         *res_ptr = LDKFilter_init(o);
8145         return (long)res_ptr;
8146 }
8147 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8148         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8149         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8150         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8151         unsigned char txid_arr[32];
8152         CHECK(txid->arr_len == 32);
8153         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8154         unsigned char (*txid_ref)[32] = &txid_arr;
8155         LDKu8slice script_pubkey_ref;
8156         script_pubkey_ref.datalen = script_pubkey->arr_len;
8157         script_pubkey_ref.data = script_pubkey->elems;
8158         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8159         FREE(script_pubkey);
8160 }
8161
8162 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8163         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8164         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8165         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8166         LDKWatchedOutput output_conv;
8167         output_conv.inner = (void*)(output & (~1));
8168         output_conv.is_owned = (output & 1) || (output == 0);
8169         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8170         output_conv = WatchedOutput_clone(&output_conv);
8171         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8172         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8173         uint32_t ret_ref = (uintptr_t)ret_copy;
8174         return ret_ref;
8175 }
8176
8177 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8178         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8179         switch(obj->tag) {
8180                 case LDKCOption_FilterZ_Some: return 0;
8181                 case LDKCOption_FilterZ_None: return 1;
8182                 default: abort();
8183         }
8184 }
8185 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8186         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8187         assert(obj->tag == LDKCOption_FilterZ_Some);
8188                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8189                         *some_ret = obj->some;
8190                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8191                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8192                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8193                                 LDKFilter_JCalls_cloned(&(*some_ret));
8194                         }
8195         return (uint32_t)some_ret;
8196 }
8197 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8198 CHECK(owner->result_ok);
8199         return &*owner->contents.result;
8200 }
8201 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8202         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8203         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8204         uint32_t ret_ref = 0;
8205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8208         ret_ref = (uintptr_t)ret_var.inner & ~1;
8209         return ret_ref;
8210 }
8211
8212 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8213 CHECK(!owner->result_ok);
8214         return *owner->contents.err;
8215 }
8216 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8217         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8218         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8219 }
8220
8221 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8222         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8223         for (size_t i = 0; i < ret.datalen; i++) {
8224                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8225         }
8226         return ret;
8227 }
8228 typedef struct LDKMessageSendEventsProvider_JCalls {
8229         atomic_size_t refcnt;
8230         uint32_t instance_ptr;
8231 } LDKMessageSendEventsProvider_JCalls;
8232 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8233         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8234         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8235                 FREE(j_calls);
8236         }
8237 }
8238 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8239         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8240         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 34);
8241         LDKCVec_MessageSendEventZ ret_constr;
8242         ret_constr.datalen = ret->arr_len;
8243         if (ret_constr.datalen > 0)
8244                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8245         else
8246                 ret_constr.data = NULL;
8247         uint32_t* ret_vals = ret->elems;
8248         for (size_t s = 0; s < ret_constr.datalen; s++) {
8249                 uint32_t ret_conv_18 = ret_vals[s];
8250                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8251                 CHECK_ACCESS(ret_conv_18_ptr);
8252                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8253                 FREE((void*)ret_conv_18);
8254                 ret_constr.data[s] = ret_conv_18_conv;
8255         }
8256         FREE(ret);
8257         return ret_constr;
8258 }
8259 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8260         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8261         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8262 }
8263 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8264         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8265         atomic_init(&calls->refcnt, 1);
8266         calls->instance_ptr = o;
8267
8268         LDKMessageSendEventsProvider ret = {
8269                 .this_arg = (void*) calls,
8270                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8271                 .free = LDKMessageSendEventsProvider_JCalls_free,
8272         };
8273         return ret;
8274 }
8275 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8276         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8277         *res_ptr = LDKMessageSendEventsProvider_init(o);
8278         return (long)res_ptr;
8279 }
8280 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) {
8281         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8282         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8283         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8284         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8285         uint32_tArray ret_arr = NULL;
8286         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8287         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8288         for (size_t s = 0; s < ret_var.datalen; s++) {
8289                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8290                 *ret_conv_18_copy = ret_var.data[s];
8291                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8292                 ret_arr_ptr[s] = ret_conv_18_ref;
8293         }
8294         
8295         FREE(ret_var.data);
8296         return ret_arr;
8297 }
8298
8299 typedef struct LDKEventHandler_JCalls {
8300         atomic_size_t refcnt;
8301         uint32_t instance_ptr;
8302 } LDKEventHandler_JCalls;
8303 static void LDKEventHandler_JCalls_free(void* this_arg) {
8304         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8305         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8306                 FREE(j_calls);
8307         }
8308 }
8309 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8310         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8311         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8312         *ret_event = Event_clone(event);
8313         js_invoke_function_u_u(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8314 }
8315 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8316         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8317         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8318 }
8319 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8320         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8321         atomic_init(&calls->refcnt, 1);
8322         calls->instance_ptr = o;
8323
8324         LDKEventHandler ret = {
8325                 .this_arg = (void*) calls,
8326                 .handle_event = handle_event_LDKEventHandler_jcall,
8327                 .free = LDKEventHandler_JCalls_free,
8328         };
8329         return ret;
8330 }
8331 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8332         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8333         *res_ptr = LDKEventHandler_init(o);
8334         return (long)res_ptr;
8335 }
8336 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8337         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8338         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8339         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8340         LDKEvent* event_conv = (LDKEvent*)event;
8341         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8342 }
8343
8344 typedef struct LDKEventsProvider_JCalls {
8345         atomic_size_t refcnt;
8346         uint32_t instance_ptr;
8347 } LDKEventsProvider_JCalls;
8348 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8349         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8350         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8351                 FREE(j_calls);
8352         }
8353 }
8354 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8355         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8356         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8357         *handler_ret = handler;
8358         js_invoke_function_u_u(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8359 }
8360 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8361         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8362         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8363 }
8364 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8365         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8366         atomic_init(&calls->refcnt, 1);
8367         calls->instance_ptr = o;
8368
8369         LDKEventsProvider ret = {
8370                 .this_arg = (void*) calls,
8371                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8372                 .free = LDKEventsProvider_JCalls_free,
8373         };
8374         return ret;
8375 }
8376 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8377         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8378         *res_ptr = LDKEventsProvider_init(o);
8379         return (long)res_ptr;
8380 }
8381 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8384         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8385         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8386         CHECK_ACCESS(handler_ptr);
8387         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8388         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8390                 LDKEventHandler_JCalls_cloned(&handler_conv);
8391         }
8392         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8393 }
8394
8395 typedef struct LDKScore_JCalls {
8396         atomic_size_t refcnt;
8397         uint32_t instance_ptr;
8398 } LDKScore_JCalls;
8399 static void LDKScore_JCalls_free(void* this_arg) {
8400         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8401         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8402                 FREE(j_calls);
8403         }
8404 }
8405 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8406         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8407         int64_t short_channel_id_conv = short_channel_id;
8408         LDKNodeId source_var = *source;
8409         uint32_t source_ref = 0;
8410         source_var = NodeId_clone(&source_var);
8411         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8412         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8413         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8414         source_ref = (uintptr_t)source_var.inner;
8415         if (source_var.is_owned) {
8416                 source_ref |= 1;
8417         }
8418         LDKNodeId target_var = *target;
8419         uint32_t target_ref = 0;
8420         target_var = NodeId_clone(&target_var);
8421         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8422         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8423         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8424         target_ref = (uintptr_t)target_var.inner;
8425         if (target_var.is_owned) {
8426                 target_ref |= 1;
8427         }
8428         LDKChannelUsage usage_var = usage;
8429         uint32_t usage_ref = 0;
8430         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8431         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8432         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8433         usage_ref = (uintptr_t)usage_var.inner;
8434         if (usage_var.is_owned) {
8435                 usage_ref |= 1;
8436         }
8437         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);
8438 }
8439 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8440         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8441         LDKCVec_RouteHopZ path_var = path;
8442         uint32_tArray path_arr = NULL;
8443         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8444         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8445         for (size_t k = 0; k < path_var.datalen; k++) {
8446                 LDKRouteHop path_conv_10_var = path_var.data[k];
8447                 uint32_t path_conv_10_ref = 0;
8448                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8449                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8451                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8452                 if (path_conv_10_var.is_owned) {
8453                         path_conv_10_ref |= 1;
8454                 }
8455                 path_arr_ptr[k] = path_conv_10_ref;
8456         }
8457         
8458         FREE(path_var.data);
8459         int64_t short_channel_id_conv = short_channel_id;
8460         js_invoke_function_u_bb(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
8461 }
8462 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8463         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8464         LDKCVec_RouteHopZ path_var = path;
8465         uint32_tArray path_arr = NULL;
8466         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8467         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8468         for (size_t k = 0; k < path_var.datalen; k++) {
8469                 LDKRouteHop path_conv_10_var = path_var.data[k];
8470                 uint32_t path_conv_10_ref = 0;
8471                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8472                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8473                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8474                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8475                 if (path_conv_10_var.is_owned) {
8476                         path_conv_10_ref |= 1;
8477                 }
8478                 path_arr_ptr[k] = path_conv_10_ref;
8479         }
8480         
8481         FREE(path_var.data);
8482         js_invoke_function_u_u(j_calls->instance_ptr, 39, (uint32_t)path_arr);
8483 }
8484 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8485         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8486         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 40);
8487         LDKCVec_u8Z ret_ref;
8488         ret_ref.datalen = ret->arr_len;
8489         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8490         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8491         return ret_ref;
8492 }
8493 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8494         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8495         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8496 }
8497 static inline LDKScore LDKScore_init (JSValue o) {
8498         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8499         atomic_init(&calls->refcnt, 1);
8500         calls->instance_ptr = o;
8501
8502         LDKScore ret = {
8503                 .this_arg = (void*) calls,
8504                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8505                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8506                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8507                 .write = write_LDKScore_jcall,
8508                 .free = LDKScore_JCalls_free,
8509         };
8510         return ret;
8511 }
8512 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8513         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8514         *res_ptr = LDKScore_init(o);
8515         return (long)res_ptr;
8516 }
8517 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) {
8518         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8519         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8520         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8521         LDKNodeId source_conv;
8522         source_conv.inner = (void*)(source & (~1));
8523         source_conv.is_owned = false;
8524         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8525         LDKNodeId target_conv;
8526         target_conv.inner = (void*)(target & (~1));
8527         target_conv.is_owned = false;
8528         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8529         LDKChannelUsage usage_conv;
8530         usage_conv.inner = (void*)(usage & (~1));
8531         usage_conv.is_owned = (usage & 1) || (usage == 0);
8532         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8533         usage_conv = ChannelUsage_clone(&usage_conv);
8534         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8535         return ret_conv;
8536 }
8537
8538 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) {
8539         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8541         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8542         LDKCVec_RouteHopZ path_constr;
8543         path_constr.datalen = path->arr_len;
8544         if (path_constr.datalen > 0)
8545                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8546         else
8547                 path_constr.data = NULL;
8548         uint32_t* path_vals = path->elems;
8549         for (size_t k = 0; k < path_constr.datalen; k++) {
8550                 uint32_t path_conv_10 = path_vals[k];
8551                 LDKRouteHop path_conv_10_conv;
8552                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8553                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8555                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8556                 path_constr.data[k] = path_conv_10_conv;
8557         }
8558         FREE(path);
8559         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8560 }
8561
8562 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8563         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8565         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8566         LDKCVec_RouteHopZ path_constr;
8567         path_constr.datalen = path->arr_len;
8568         if (path_constr.datalen > 0)
8569                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8570         else
8571                 path_constr.data = NULL;
8572         uint32_t* path_vals = path->elems;
8573         for (size_t k = 0; k < path_constr.datalen; k++) {
8574                 uint32_t path_conv_10 = path_vals[k];
8575                 LDKRouteHop path_conv_10_conv;
8576                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8577                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8578                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8579                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8580                 path_constr.data[k] = path_conv_10_conv;
8581         }
8582         FREE(path);
8583         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8584 }
8585
8586 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8589         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8590         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8591         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8592         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8593         CVec_u8Z_free(ret_var);
8594         return ret_arr;
8595 }
8596
8597 typedef struct LDKPersister_JCalls {
8598         atomic_size_t refcnt;
8599         uint32_t instance_ptr;
8600 } LDKPersister_JCalls;
8601 static void LDKPersister_JCalls_free(void* this_arg) {
8602         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8603         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8604                 FREE(j_calls);
8605         }
8606 }
8607 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8608         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8609         LDKChannelManager channel_manager_var = *channel_manager;
8610         uint32_t channel_manager_ref = 0;
8611         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8612         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8613         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8614         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8615         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8616         if (channel_manager_var.is_owned) {
8617                 channel_manager_ref |= 1;
8618         }
8619         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 41, (uint32_t)channel_manager_ref);
8620         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8621         CHECK_ACCESS(ret_ptr);
8622         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8623         FREE((void*)ret);
8624         return ret_conv;
8625 }
8626 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8627         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8628         LDKNetworkGraph network_graph_var = *network_graph;
8629         uint32_t network_graph_ref = 0;
8630         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8631         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8632         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8633         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8634         network_graph_ref = (uintptr_t)network_graph_var.inner;
8635         if (network_graph_var.is_owned) {
8636                 network_graph_ref |= 1;
8637         }
8638         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 42, (uint32_t)network_graph_ref);
8639         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8640         CHECK_ACCESS(ret_ptr);
8641         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8642         FREE((void*)ret);
8643         return ret_conv;
8644 }
8645 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8646         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8647         LDKMultiThreadedLockableScore scorer_var = *scorer;
8648         uint32_t scorer_ref = 0;
8649         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8650         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8651         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8652         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8653         scorer_ref = (uintptr_t)scorer_var.inner;
8654         if (scorer_var.is_owned) {
8655                 scorer_ref |= 1;
8656         }
8657         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 43, (uint32_t)scorer_ref);
8658         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8659         CHECK_ACCESS(ret_ptr);
8660         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8661         FREE((void*)ret);
8662         return ret_conv;
8663 }
8664 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8665         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8666         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8667 }
8668 static inline LDKPersister LDKPersister_init (JSValue o) {
8669         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8670         atomic_init(&calls->refcnt, 1);
8671         calls->instance_ptr = o;
8672
8673         LDKPersister ret = {
8674                 .this_arg = (void*) calls,
8675                 .persist_manager = persist_manager_LDKPersister_jcall,
8676                 .persist_graph = persist_graph_LDKPersister_jcall,
8677                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8678                 .free = LDKPersister_JCalls_free,
8679         };
8680         return ret;
8681 }
8682 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8683         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8684         *res_ptr = LDKPersister_init(o);
8685         return (long)res_ptr;
8686 }
8687 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8688         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8689         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8690         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8691         LDKChannelManager channel_manager_conv;
8692         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8693         channel_manager_conv.is_owned = false;
8694         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8695         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8696         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8697         return (uint32_t)ret_conv;
8698 }
8699
8700 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8701         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8702         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8703         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8704         LDKNetworkGraph network_graph_conv;
8705         network_graph_conv.inner = (void*)(network_graph & (~1));
8706         network_graph_conv.is_owned = false;
8707         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8708         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8709         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
8710         return (uint32_t)ret_conv;
8711 }
8712
8713 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
8714         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8715         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8716         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8717         LDKMultiThreadedLockableScore scorer_conv;
8718         scorer_conv.inner = (void*)(scorer & (~1));
8719         scorer_conv.is_owned = false;
8720         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
8721         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8722         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
8723         return (uint32_t)ret_conv;
8724 }
8725
8726 typedef struct LDKListen_JCalls {
8727         atomic_size_t refcnt;
8728         uint32_t instance_ptr;
8729 } LDKListen_JCalls;
8730 static void LDKListen_JCalls_free(void* this_arg) {
8731         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8732         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8733                 FREE(j_calls);
8734         }
8735 }
8736 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8737         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8738         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8739         memcpy(header_arr->elems, *header, 80);
8740         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8741         uint32_tArray txdata_arr = NULL;
8742         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8743         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8744         for (size_t c = 0; c < txdata_var.datalen; c++) {
8745                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8746                 *txdata_conv_28_conv = txdata_var.data[c];
8747                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8748         }
8749         
8750         FREE(txdata_var.data);
8751         int32_t height_conv = height;
8752         js_invoke_function_u_uuu(j_calls->instance_ptr, 44, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8753 }
8754 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8755         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8756         LDKu8slice block_var = block;
8757         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8758         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8759         int32_t height_conv = height;
8760         js_invoke_function_u_uu(j_calls->instance_ptr, 45, (uint32_t)block_arr, (uint32_t)height_conv);
8761 }
8762 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8763         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8764         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8765         memcpy(header_arr->elems, *header, 80);
8766         int32_t height_conv = height;
8767         js_invoke_function_u_uu(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)height_conv);
8768 }
8769 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8770         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8771         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8772 }
8773 static inline LDKListen LDKListen_init (JSValue o) {
8774         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8775         atomic_init(&calls->refcnt, 1);
8776         calls->instance_ptr = o;
8777
8778         LDKListen ret = {
8779                 .this_arg = (void*) calls,
8780                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
8781                 .block_connected = block_connected_LDKListen_jcall,
8782                 .block_disconnected = block_disconnected_LDKListen_jcall,
8783                 .free = LDKListen_JCalls_free,
8784         };
8785         return ret;
8786 }
8787 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8788         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8789         *res_ptr = LDKListen_init(o);
8790         return (long)res_ptr;
8791 }
8792 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) {
8793         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8794         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8795         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8796         unsigned char header_arr[80];
8797         CHECK(header->arr_len == 80);
8798         memcpy(header_arr, header->elems, 80); FREE(header);
8799         unsigned char (*header_ref)[80] = &header_arr;
8800         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8801         txdata_constr.datalen = txdata->arr_len;
8802         if (txdata_constr.datalen > 0)
8803                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8804         else
8805                 txdata_constr.data = NULL;
8806         uint32_t* txdata_vals = txdata->elems;
8807         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8808                 uint32_t txdata_conv_28 = txdata_vals[c];
8809                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8810                 CHECK_ACCESS(txdata_conv_28_ptr);
8811                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8812                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8813                 txdata_constr.data[c] = txdata_conv_28_conv;
8814         }
8815         FREE(txdata);
8816         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8817 }
8818
8819 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8820         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8821         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8822         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8823         LDKu8slice block_ref;
8824         block_ref.datalen = block->arr_len;
8825         block_ref.data = block->elems;
8826         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8827         FREE(block);
8828 }
8829
8830 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8833         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8834         unsigned char header_arr[80];
8835         CHECK(header->arr_len == 80);
8836         memcpy(header_arr, header->elems, 80); FREE(header);
8837         unsigned char (*header_ref)[80] = &header_arr;
8838         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8839 }
8840
8841 typedef struct LDKConfirm_JCalls {
8842         atomic_size_t refcnt;
8843         uint32_t instance_ptr;
8844 } LDKConfirm_JCalls;
8845 static void LDKConfirm_JCalls_free(void* this_arg) {
8846         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8847         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8848                 FREE(j_calls);
8849         }
8850 }
8851 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8852         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8853         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8854         memcpy(header_arr->elems, *header, 80);
8855         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8856         uint32_tArray txdata_arr = NULL;
8857         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8858         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8859         for (size_t c = 0; c < txdata_var.datalen; c++) {
8860                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8861                 *txdata_conv_28_conv = txdata_var.data[c];
8862                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8863         }
8864         
8865         FREE(txdata_var.data);
8866         int32_t height_conv = height;
8867         js_invoke_function_u_uuu(j_calls->instance_ptr, 47, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8868 }
8869 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8870         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8871         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8872         memcpy(txid_arr->elems, *txid, 32);
8873         js_invoke_function_u_u(j_calls->instance_ptr, 48, (uint32_t)txid_arr);
8874 }
8875 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8876         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8877         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8878         memcpy(header_arr->elems, *header, 80);
8879         int32_t height_conv = height;
8880         js_invoke_function_u_uu(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)height_conv);
8881 }
8882 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8883         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8884         ptrArray ret = (ptrArray)js_invoke_function_u_(j_calls->instance_ptr, 50);
8885         LDKCVec_TxidZ ret_constr;
8886         ret_constr.datalen = ret->arr_len;
8887         if (ret_constr.datalen > 0)
8888                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8889         else
8890                 ret_constr.data = NULL;
8891         int8_tArray* ret_vals = (void*) ret->elems;
8892         for (size_t m = 0; m < ret_constr.datalen; m++) {
8893                 int8_tArray ret_conv_12 = ret_vals[m];
8894                 LDKThirtyTwoBytes ret_conv_12_ref;
8895                 CHECK(ret_conv_12->arr_len == 32);
8896                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8897                 ret_constr.data[m] = ret_conv_12_ref;
8898         }
8899         FREE(ret);
8900         return ret_constr;
8901 }
8902 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8903         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8904         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8905 }
8906 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8907         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8908         atomic_init(&calls->refcnt, 1);
8909         calls->instance_ptr = o;
8910
8911         LDKConfirm ret = {
8912                 .this_arg = (void*) calls,
8913                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8914                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8915                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8916                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8917                 .free = LDKConfirm_JCalls_free,
8918         };
8919         return ret;
8920 }
8921 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8922         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8923         *res_ptr = LDKConfirm_init(o);
8924         return (long)res_ptr;
8925 }
8926 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) {
8927         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8928         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8929         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8930         unsigned char header_arr[80];
8931         CHECK(header->arr_len == 80);
8932         memcpy(header_arr, header->elems, 80); FREE(header);
8933         unsigned char (*header_ref)[80] = &header_arr;
8934         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8935         txdata_constr.datalen = txdata->arr_len;
8936         if (txdata_constr.datalen > 0)
8937                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8938         else
8939                 txdata_constr.data = NULL;
8940         uint32_t* txdata_vals = txdata->elems;
8941         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8942                 uint32_t txdata_conv_28 = txdata_vals[c];
8943                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8944                 CHECK_ACCESS(txdata_conv_28_ptr);
8945                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8946                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8947                 txdata_constr.data[c] = txdata_conv_28_conv;
8948         }
8949         FREE(txdata);
8950         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8951 }
8952
8953 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8954         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8955         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8956         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8957         unsigned char txid_arr[32];
8958         CHECK(txid->arr_len == 32);
8959         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8960         unsigned char (*txid_ref)[32] = &txid_arr;
8961         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8962 }
8963
8964 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8965         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8966         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8967         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8968         unsigned char header_arr[80];
8969         CHECK(header->arr_len == 80);
8970         memcpy(header_arr, header->elems, 80); FREE(header);
8971         unsigned char (*header_ref)[80] = &header_arr;
8972         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8973 }
8974
8975 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8976         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8977         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8978         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8979         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8980         ptrArray ret_arr = NULL;
8981         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8982         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8983         for (size_t m = 0; m < ret_var.datalen; m++) {
8984                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8985                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8986                 ret_arr_ptr[m] = ret_conv_12_arr;
8987         }
8988         
8989         FREE(ret_var.data);
8990         return ret_arr;
8991 }
8992
8993 typedef struct LDKPersist_JCalls {
8994         atomic_size_t refcnt;
8995         uint32_t instance_ptr;
8996 } LDKPersist_JCalls;
8997 static void LDKPersist_JCalls_free(void* this_arg) {
8998         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8999         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9000                 FREE(j_calls);
9001         }
9002 }
9003 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9004         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9005         LDKOutPoint channel_id_var = channel_id;
9006         uint32_t channel_id_ref = 0;
9007         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9008         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9009         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9010         channel_id_ref = (uintptr_t)channel_id_var.inner;
9011         if (channel_id_var.is_owned) {
9012                 channel_id_ref |= 1;
9013         }
9014         LDKChannelMonitor data_var = *data;
9015         uint32_t data_ref = 0;
9016         data_var = ChannelMonitor_clone(&data_var);
9017         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9018         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9019         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9020         data_ref = (uintptr_t)data_var.inner;
9021         if (data_var.is_owned) {
9022                 data_ref |= 1;
9023         }
9024         LDKMonitorUpdateId update_id_var = update_id;
9025         uint32_t update_id_ref = 0;
9026         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9027         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9028         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9029         update_id_ref = (uintptr_t)update_id_var.inner;
9030         if (update_id_var.is_owned) {
9031                 update_id_ref |= 1;
9032         }
9033         uint32_t ret = js_invoke_function_u_uuu(j_calls->instance_ptr, 51, (uint32_t)channel_id_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
9034         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9035         CHECK_ACCESS(ret_ptr);
9036         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9037         FREE((void*)ret);
9038         return ret_conv;
9039 }
9040 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9041         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9042         LDKOutPoint channel_id_var = channel_id;
9043         uint32_t channel_id_ref = 0;
9044         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9045         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9046         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9047         channel_id_ref = (uintptr_t)channel_id_var.inner;
9048         if (channel_id_var.is_owned) {
9049                 channel_id_ref |= 1;
9050         }
9051         LDKChannelMonitorUpdate update_var = *update;
9052         uint32_t update_ref = 0;
9053         if ((uintptr_t)update_var.inner > 4096) {
9054                 update_var = ChannelMonitorUpdate_clone(&update_var);
9055                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9056                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9057         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9058                 update_ref = (uintptr_t)update_var.inner;
9059                 if (update_var.is_owned) {
9060                         update_ref |= 1;
9061                 }
9062         }
9063         LDKChannelMonitor data_var = *data;
9064         uint32_t data_ref = 0;
9065         data_var = ChannelMonitor_clone(&data_var);
9066         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9067         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9068         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9069         data_ref = (uintptr_t)data_var.inner;
9070         if (data_var.is_owned) {
9071                 data_ref |= 1;
9072         }
9073         LDKMonitorUpdateId update_id_var = update_id;
9074         uint32_t update_id_ref = 0;
9075         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9076         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9077         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9078         update_id_ref = (uintptr_t)update_id_var.inner;
9079         if (update_id_var.is_owned) {
9080                 update_id_ref |= 1;
9081         }
9082         uint32_t ret = js_invoke_function_u_uuuu(j_calls->instance_ptr, 52, (uint32_t)channel_id_ref, (uint32_t)update_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
9083         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9084         CHECK_ACCESS(ret_ptr);
9085         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9086         FREE((void*)ret);
9087         return ret_conv;
9088 }
9089 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9090         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9091         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9092 }
9093 static inline LDKPersist LDKPersist_init (JSValue o) {
9094         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9095         atomic_init(&calls->refcnt, 1);
9096         calls->instance_ptr = o;
9097
9098         LDKPersist ret = {
9099                 .this_arg = (void*) calls,
9100                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9101                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9102                 .free = LDKPersist_JCalls_free,
9103         };
9104         return ret;
9105 }
9106 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9107         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9108         *res_ptr = LDKPersist_init(o);
9109         return (long)res_ptr;
9110 }
9111 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) {
9112         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9113         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9114         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9115         LDKOutPoint channel_id_conv;
9116         channel_id_conv.inner = (void*)(channel_id & (~1));
9117         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9118         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9119         channel_id_conv = OutPoint_clone(&channel_id_conv);
9120         LDKChannelMonitor data_conv;
9121         data_conv.inner = (void*)(data & (~1));
9122         data_conv.is_owned = false;
9123         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9124         LDKMonitorUpdateId update_id_conv;
9125         update_id_conv.inner = (void*)(update_id & (~1));
9126         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9127         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9128         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9129         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9130         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9131         return (uint32_t)ret_conv;
9132 }
9133
9134 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) {
9135         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9136         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9137         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9138         LDKOutPoint channel_id_conv;
9139         channel_id_conv.inner = (void*)(channel_id & (~1));
9140         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9141         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9142         channel_id_conv = OutPoint_clone(&channel_id_conv);
9143         LDKChannelMonitorUpdate update_conv;
9144         update_conv.inner = (void*)(update & (~1));
9145         update_conv.is_owned = false;
9146         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9147         LDKChannelMonitor data_conv;
9148         data_conv.inner = (void*)(data & (~1));
9149         data_conv.is_owned = false;
9150         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9151         LDKMonitorUpdateId update_id_conv;
9152         update_id_conv.inner = (void*)(update_id & (~1));
9153         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9154         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9155         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9156         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9157         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9158         return (uint32_t)ret_conv;
9159 }
9160
9161 typedef struct LDKChannelMessageHandler_JCalls {
9162         atomic_size_t refcnt;
9163         uint32_t instance_ptr;
9164         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9165 } LDKChannelMessageHandler_JCalls;
9166 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9167         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9168         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9169                 FREE(j_calls);
9170         }
9171 }
9172 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9173         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9174         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9175         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9176         LDKInitFeatures their_features_var = their_features;
9177         uint32_t their_features_ref = 0;
9178         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9179         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9180         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9181         their_features_ref = (uintptr_t)their_features_var.inner;
9182         if (their_features_var.is_owned) {
9183                 their_features_ref |= 1;
9184         }
9185         LDKOpenChannel msg_var = *msg;
9186         uint32_t msg_ref = 0;
9187         msg_var = OpenChannel_clone(&msg_var);
9188         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9189         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9190         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9191         msg_ref = (uintptr_t)msg_var.inner;
9192         if (msg_var.is_owned) {
9193                 msg_ref |= 1;
9194         }
9195         js_invoke_function_u_uuu(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9196 }
9197 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9199         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9200         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9201         LDKInitFeatures their_features_var = their_features;
9202         uint32_t their_features_ref = 0;
9203         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9204         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9205         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9206         their_features_ref = (uintptr_t)their_features_var.inner;
9207         if (their_features_var.is_owned) {
9208                 their_features_ref |= 1;
9209         }
9210         LDKAcceptChannel msg_var = *msg;
9211         uint32_t msg_ref = 0;
9212         msg_var = AcceptChannel_clone(&msg_var);
9213         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9214         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9215         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9216         msg_ref = (uintptr_t)msg_var.inner;
9217         if (msg_var.is_owned) {
9218                 msg_ref |= 1;
9219         }
9220         js_invoke_function_u_uuu(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9221 }
9222 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9223         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9224         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9225         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9226         LDKFundingCreated msg_var = *msg;
9227         uint32_t msg_ref = 0;
9228         msg_var = FundingCreated_clone(&msg_var);
9229         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9230         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9231         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9232         msg_ref = (uintptr_t)msg_var.inner;
9233         if (msg_var.is_owned) {
9234                 msg_ref |= 1;
9235         }
9236         js_invoke_function_u_uu(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9237 }
9238 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9239         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9240         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9241         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9242         LDKFundingSigned msg_var = *msg;
9243         uint32_t msg_ref = 0;
9244         msg_var = FundingSigned_clone(&msg_var);
9245         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9246         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9247         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9248         msg_ref = (uintptr_t)msg_var.inner;
9249         if (msg_var.is_owned) {
9250                 msg_ref |= 1;
9251         }
9252         js_invoke_function_u_uu(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9253 }
9254 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9255         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9256         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9257         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9258         LDKChannelReady msg_var = *msg;
9259         uint32_t msg_ref = 0;
9260         msg_var = ChannelReady_clone(&msg_var);
9261         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9262         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9263         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9264         msg_ref = (uintptr_t)msg_var.inner;
9265         if (msg_var.is_owned) {
9266                 msg_ref |= 1;
9267         }
9268         js_invoke_function_u_uu(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9269 }
9270 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9271         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9272         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9273         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9274         LDKInitFeatures their_features_var = *their_features;
9275         uint32_t their_features_ref = 0;
9276         their_features_var = InitFeatures_clone(&their_features_var);
9277         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9278         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9279         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9280         their_features_ref = (uintptr_t)their_features_var.inner;
9281         if (their_features_var.is_owned) {
9282                 their_features_ref |= 1;
9283         }
9284         LDKShutdown msg_var = *msg;
9285         uint32_t msg_ref = 0;
9286         msg_var = Shutdown_clone(&msg_var);
9287         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9288         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9290         msg_ref = (uintptr_t)msg_var.inner;
9291         if (msg_var.is_owned) {
9292                 msg_ref |= 1;
9293         }
9294         js_invoke_function_u_uuu(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9295 }
9296 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9297         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9298         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9299         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9300         LDKClosingSigned msg_var = *msg;
9301         uint32_t msg_ref = 0;
9302         msg_var = ClosingSigned_clone(&msg_var);
9303         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9304         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9305         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9306         msg_ref = (uintptr_t)msg_var.inner;
9307         if (msg_var.is_owned) {
9308                 msg_ref |= 1;
9309         }
9310         js_invoke_function_u_uu(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9311 }
9312 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9313         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9314         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9315         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9316         LDKUpdateAddHTLC msg_var = *msg;
9317         uint32_t msg_ref = 0;
9318         msg_var = UpdateAddHTLC_clone(&msg_var);
9319         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9320         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9322         msg_ref = (uintptr_t)msg_var.inner;
9323         if (msg_var.is_owned) {
9324                 msg_ref |= 1;
9325         }
9326         js_invoke_function_u_uu(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9327 }
9328 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9329         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9330         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9331         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9332         LDKUpdateFulfillHTLC msg_var = *msg;
9333         uint32_t msg_ref = 0;
9334         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9335         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9336         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9337         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9338         msg_ref = (uintptr_t)msg_var.inner;
9339         if (msg_var.is_owned) {
9340                 msg_ref |= 1;
9341         }
9342         js_invoke_function_u_uu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9343 }
9344 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9345         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9346         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9347         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9348         LDKUpdateFailHTLC msg_var = *msg;
9349         uint32_t msg_ref = 0;
9350         msg_var = UpdateFailHTLC_clone(&msg_var);
9351         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9352         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9354         msg_ref = (uintptr_t)msg_var.inner;
9355         if (msg_var.is_owned) {
9356                 msg_ref |= 1;
9357         }
9358         js_invoke_function_u_uu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9359 }
9360 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9361         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9362         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9363         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9364         LDKUpdateFailMalformedHTLC msg_var = *msg;
9365         uint32_t msg_ref = 0;
9366         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9367         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9368         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9369         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9370         msg_ref = (uintptr_t)msg_var.inner;
9371         if (msg_var.is_owned) {
9372                 msg_ref |= 1;
9373         }
9374         js_invoke_function_u_uu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9375 }
9376 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9377         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9378         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9379         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9380         LDKCommitmentSigned msg_var = *msg;
9381         uint32_t msg_ref = 0;
9382         msg_var = CommitmentSigned_clone(&msg_var);
9383         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9384         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9385         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9386         msg_ref = (uintptr_t)msg_var.inner;
9387         if (msg_var.is_owned) {
9388                 msg_ref |= 1;
9389         }
9390         js_invoke_function_u_uu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9391 }
9392 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9393         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9394         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9395         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9396         LDKRevokeAndACK msg_var = *msg;
9397         uint32_t msg_ref = 0;
9398         msg_var = RevokeAndACK_clone(&msg_var);
9399         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9400         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9401         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9402         msg_ref = (uintptr_t)msg_var.inner;
9403         if (msg_var.is_owned) {
9404                 msg_ref |= 1;
9405         }
9406         js_invoke_function_u_uu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9407 }
9408 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9409         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9410         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9411         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9412         LDKUpdateFee msg_var = *msg;
9413         uint32_t msg_ref = 0;
9414         msg_var = UpdateFee_clone(&msg_var);
9415         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9416         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9418         msg_ref = (uintptr_t)msg_var.inner;
9419         if (msg_var.is_owned) {
9420                 msg_ref |= 1;
9421         }
9422         js_invoke_function_u_uu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9423 }
9424 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9425         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9426         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9427         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9428         LDKAnnouncementSignatures msg_var = *msg;
9429         uint32_t msg_ref = 0;
9430         msg_var = AnnouncementSignatures_clone(&msg_var);
9431         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9432         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9434         msg_ref = (uintptr_t)msg_var.inner;
9435         if (msg_var.is_owned) {
9436                 msg_ref |= 1;
9437         }
9438         js_invoke_function_u_uu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9439 }
9440 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9441         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9442         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9443         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9444         jboolean no_connection_possible_conv = no_connection_possible;
9445         js_invoke_function_u_uu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
9446 }
9447 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9449         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9450         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9451         LDKInit msg_var = *msg;
9452         uint32_t msg_ref = 0;
9453         msg_var = Init_clone(&msg_var);
9454         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9455         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9457         msg_ref = (uintptr_t)msg_var.inner;
9458         if (msg_var.is_owned) {
9459                 msg_ref |= 1;
9460         }
9461         js_invoke_function_u_uu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9462 }
9463 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * 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         LDKChannelReestablish msg_var = *msg;
9468         uint32_t msg_ref = 0;
9469         msg_var = ChannelReestablish_clone(&msg_var);
9470         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9471         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9473         msg_ref = (uintptr_t)msg_var.inner;
9474         if (msg_var.is_owned) {
9475                 msg_ref |= 1;
9476         }
9477         js_invoke_function_u_uu(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9478 }
9479 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9481         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9482         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9483         LDKChannelUpdate msg_var = *msg;
9484         uint32_t msg_ref = 0;
9485         msg_var = ChannelUpdate_clone(&msg_var);
9486         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9487         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9489         msg_ref = (uintptr_t)msg_var.inner;
9490         if (msg_var.is_owned) {
9491                 msg_ref |= 1;
9492         }
9493         js_invoke_function_u_uu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9494 }
9495 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9496         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9497         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9498         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9499         LDKErrorMessage msg_var = *msg;
9500         uint32_t msg_ref = 0;
9501         msg_var = ErrorMessage_clone(&msg_var);
9502         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9503         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9505         msg_ref = (uintptr_t)msg_var.inner;
9506         if (msg_var.is_owned) {
9507                 msg_ref |= 1;
9508         }
9509         js_invoke_function_u_uu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9510 }
9511 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9512         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9514         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9515 }
9516 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9517         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9518         atomic_init(&calls->refcnt, 1);
9519         calls->instance_ptr = o;
9520
9521         LDKChannelMessageHandler ret = {
9522                 .this_arg = (void*) calls,
9523                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9524                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9525                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9526                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9527                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9528                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9529                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9530                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9531                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9532                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9533                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9534                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9535                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9536                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9537                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9538                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9539                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9540                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9541                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9542                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9543                 .free = LDKChannelMessageHandler_JCalls_free,
9544                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9545         };
9546         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9547         return ret;
9548 }
9549 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9550         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9551         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9552         return (long)res_ptr;
9553 }
9554 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) {
9555         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9556         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9557         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9558         LDKPublicKey their_node_id_ref;
9559         CHECK(their_node_id->arr_len == 33);
9560         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9561         LDKInitFeatures their_features_conv;
9562         their_features_conv.inner = (void*)(their_features & (~1));
9563         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9564         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9565         their_features_conv = InitFeatures_clone(&their_features_conv);
9566         LDKOpenChannel msg_conv;
9567         msg_conv.inner = (void*)(msg & (~1));
9568         msg_conv.is_owned = false;
9569         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9570         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9571 }
9572
9573 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) {
9574         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9575         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9576         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9577         LDKPublicKey their_node_id_ref;
9578         CHECK(their_node_id->arr_len == 33);
9579         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9580         LDKInitFeatures their_features_conv;
9581         their_features_conv.inner = (void*)(their_features & (~1));
9582         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9583         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9584         their_features_conv = InitFeatures_clone(&their_features_conv);
9585         LDKAcceptChannel msg_conv;
9586         msg_conv.inner = (void*)(msg & (~1));
9587         msg_conv.is_owned = false;
9588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9589         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9590 }
9591
9592 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) {
9593         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9594         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9595         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9596         LDKPublicKey their_node_id_ref;
9597         CHECK(their_node_id->arr_len == 33);
9598         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9599         LDKFundingCreated msg_conv;
9600         msg_conv.inner = (void*)(msg & (~1));
9601         msg_conv.is_owned = false;
9602         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9603         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9604 }
9605
9606 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) {
9607         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9608         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9609         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9610         LDKPublicKey their_node_id_ref;
9611         CHECK(their_node_id->arr_len == 33);
9612         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9613         LDKFundingSigned msg_conv;
9614         msg_conv.inner = (void*)(msg & (~1));
9615         msg_conv.is_owned = false;
9616         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9617         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9618 }
9619
9620 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) {
9621         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9622         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9623         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9624         LDKPublicKey their_node_id_ref;
9625         CHECK(their_node_id->arr_len == 33);
9626         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9627         LDKChannelReady msg_conv;
9628         msg_conv.inner = (void*)(msg & (~1));
9629         msg_conv.is_owned = false;
9630         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9631         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9632 }
9633
9634 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) {
9635         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9636         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9637         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9638         LDKPublicKey their_node_id_ref;
9639         CHECK(their_node_id->arr_len == 33);
9640         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9641         LDKInitFeatures their_features_conv;
9642         their_features_conv.inner = (void*)(their_features & (~1));
9643         their_features_conv.is_owned = false;
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9645         LDKShutdown msg_conv;
9646         msg_conv.inner = (void*)(msg & (~1));
9647         msg_conv.is_owned = false;
9648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9649         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9650 }
9651
9652 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) {
9653         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9654         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9655         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9656         LDKPublicKey their_node_id_ref;
9657         CHECK(their_node_id->arr_len == 33);
9658         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9659         LDKClosingSigned msg_conv;
9660         msg_conv.inner = (void*)(msg & (~1));
9661         msg_conv.is_owned = false;
9662         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9663         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9664 }
9665
9666 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) {
9667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9669         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9670         LDKPublicKey their_node_id_ref;
9671         CHECK(their_node_id->arr_len == 33);
9672         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9673         LDKUpdateAddHTLC msg_conv;
9674         msg_conv.inner = (void*)(msg & (~1));
9675         msg_conv.is_owned = false;
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9677         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9678 }
9679
9680 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) {
9681         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9682         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9683         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9684         LDKPublicKey their_node_id_ref;
9685         CHECK(their_node_id->arr_len == 33);
9686         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9687         LDKUpdateFulfillHTLC msg_conv;
9688         msg_conv.inner = (void*)(msg & (~1));
9689         msg_conv.is_owned = false;
9690         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9691         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9692 }
9693
9694 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) {
9695         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9696         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9697         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9698         LDKPublicKey their_node_id_ref;
9699         CHECK(their_node_id->arr_len == 33);
9700         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9701         LDKUpdateFailHTLC msg_conv;
9702         msg_conv.inner = (void*)(msg & (~1));
9703         msg_conv.is_owned = false;
9704         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9705         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9706 }
9707
9708 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) {
9709         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9710         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9711         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9712         LDKPublicKey their_node_id_ref;
9713         CHECK(their_node_id->arr_len == 33);
9714         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9715         LDKUpdateFailMalformedHTLC msg_conv;
9716         msg_conv.inner = (void*)(msg & (~1));
9717         msg_conv.is_owned = false;
9718         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9719         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9720 }
9721
9722 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) {
9723         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9724         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9725         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9726         LDKPublicKey their_node_id_ref;
9727         CHECK(their_node_id->arr_len == 33);
9728         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9729         LDKCommitmentSigned msg_conv;
9730         msg_conv.inner = (void*)(msg & (~1));
9731         msg_conv.is_owned = false;
9732         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9733         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9734 }
9735
9736 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) {
9737         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9738         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9739         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9740         LDKPublicKey their_node_id_ref;
9741         CHECK(their_node_id->arr_len == 33);
9742         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9743         LDKRevokeAndACK msg_conv;
9744         msg_conv.inner = (void*)(msg & (~1));
9745         msg_conv.is_owned = false;
9746         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9747         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9748 }
9749
9750 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) {
9751         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9752         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9753         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9754         LDKPublicKey their_node_id_ref;
9755         CHECK(their_node_id->arr_len == 33);
9756         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9757         LDKUpdateFee msg_conv;
9758         msg_conv.inner = (void*)(msg & (~1));
9759         msg_conv.is_owned = false;
9760         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9761         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9762 }
9763
9764 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) {
9765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9767         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9768         LDKPublicKey their_node_id_ref;
9769         CHECK(their_node_id->arr_len == 33);
9770         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9771         LDKAnnouncementSignatures msg_conv;
9772         msg_conv.inner = (void*)(msg & (~1));
9773         msg_conv.is_owned = false;
9774         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9775         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9776 }
9777
9778 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) {
9779         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9780         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9781         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9782         LDKPublicKey their_node_id_ref;
9783         CHECK(their_node_id->arr_len == 33);
9784         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9785         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9786 }
9787
9788 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9789         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9790         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9791         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9792         LDKPublicKey their_node_id_ref;
9793         CHECK(their_node_id->arr_len == 33);
9794         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9795         LDKInit msg_conv;
9796         msg_conv.inner = (void*)(msg & (~1));
9797         msg_conv.is_owned = false;
9798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9799         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9800 }
9801
9802 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) {
9803         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9804         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9805         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9806         LDKPublicKey their_node_id_ref;
9807         CHECK(their_node_id->arr_len == 33);
9808         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9809         LDKChannelReestablish msg_conv;
9810         msg_conv.inner = (void*)(msg & (~1));
9811         msg_conv.is_owned = false;
9812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9813         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9814 }
9815
9816 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) {
9817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9820         LDKPublicKey their_node_id_ref;
9821         CHECK(their_node_id->arr_len == 33);
9822         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9823         LDKChannelUpdate msg_conv;
9824         msg_conv.inner = (void*)(msg & (~1));
9825         msg_conv.is_owned = false;
9826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9827         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9828 }
9829
9830 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9833         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9834         LDKPublicKey their_node_id_ref;
9835         CHECK(their_node_id->arr_len == 33);
9836         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9837         LDKErrorMessage msg_conv;
9838         msg_conv.inner = (void*)(msg & (~1));
9839         msg_conv.is_owned = false;
9840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9841         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9842 }
9843
9844 typedef struct LDKRoutingMessageHandler_JCalls {
9845         atomic_size_t refcnt;
9846         uint32_t instance_ptr;
9847         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9848 } LDKRoutingMessageHandler_JCalls;
9849 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9850         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9851         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9852                 FREE(j_calls);
9853         }
9854 }
9855 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9856         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9857         LDKNodeAnnouncement msg_var = *msg;
9858         uint32_t msg_ref = 0;
9859         msg_var = NodeAnnouncement_clone(&msg_var);
9860         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9861         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9863         msg_ref = (uintptr_t)msg_var.inner;
9864         if (msg_var.is_owned) {
9865                 msg_ref |= 1;
9866         }
9867         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 73, (uint32_t)msg_ref);
9868         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9869         CHECK_ACCESS(ret_ptr);
9870         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9871         FREE((void*)ret);
9872         return ret_conv;
9873 }
9874 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9875         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9876         LDKChannelAnnouncement msg_var = *msg;
9877         uint32_t msg_ref = 0;
9878         msg_var = ChannelAnnouncement_clone(&msg_var);
9879         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9880         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9882         msg_ref = (uintptr_t)msg_var.inner;
9883         if (msg_var.is_owned) {
9884                 msg_ref |= 1;
9885         }
9886         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 74, (uint32_t)msg_ref);
9887         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9888         CHECK_ACCESS(ret_ptr);
9889         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9890         FREE((void*)ret);
9891         return ret_conv;
9892 }
9893 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9894         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9895         LDKChannelUpdate msg_var = *msg;
9896         uint32_t msg_ref = 0;
9897         msg_var = ChannelUpdate_clone(&msg_var);
9898         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9899         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9901         msg_ref = (uintptr_t)msg_var.inner;
9902         if (msg_var.is_owned) {
9903                 msg_ref |= 1;
9904         }
9905         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 75, (uint32_t)msg_ref);
9906         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9907         CHECK_ACCESS(ret_ptr);
9908         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9909         FREE((void*)ret);
9910         return ret_conv;
9911 }
9912 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9913         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9914         int64_t starting_point_conv = starting_point;
9915         int8_t batch_amount_conv = batch_amount;
9916         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_uu(j_calls->instance_ptr, 76, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv);
9917         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9918         ret_constr.datalen = ret->arr_len;
9919         if (ret_constr.datalen > 0)
9920                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9921         else
9922                 ret_constr.data = NULL;
9923         uint32_t* ret_vals = ret->elems;
9924         for (size_t h = 0; h < ret_constr.datalen; h++) {
9925                 uint32_t ret_conv_59 = ret_vals[h];
9926                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9927                 CHECK_ACCESS(ret_conv_59_ptr);
9928                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9929                 FREE((void*)ret_conv_59);
9930                 ret_constr.data[h] = ret_conv_59_conv;
9931         }
9932         FREE(ret);
9933         return ret_constr;
9934 }
9935 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9936         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9937         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9938         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9939         int8_t batch_amount_conv = batch_amount;
9940         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_uu(j_calls->instance_ptr, 77, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv);
9941         LDKCVec_NodeAnnouncementZ ret_constr;
9942         ret_constr.datalen = ret->arr_len;
9943         if (ret_constr.datalen > 0)
9944                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9945         else
9946                 ret_constr.data = NULL;
9947         uint32_t* ret_vals = ret->elems;
9948         for (size_t s = 0; s < ret_constr.datalen; s++) {
9949                 uint32_t ret_conv_18 = ret_vals[s];
9950                 LDKNodeAnnouncement ret_conv_18_conv;
9951                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9952                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9953                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9954                 ret_constr.data[s] = ret_conv_18_conv;
9955         }
9956         FREE(ret);
9957         return ret_constr;
9958 }
9959 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9960         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9961         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9962         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9963         LDKInit init_var = *init;
9964         uint32_t init_ref = 0;
9965         init_var = Init_clone(&init_var);
9966         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9967         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9968         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9969         init_ref = (uintptr_t)init_var.inner;
9970         if (init_var.is_owned) {
9971                 init_ref |= 1;
9972         }
9973         js_invoke_function_u_uu(j_calls->instance_ptr, 78, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9974 }
9975 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9976         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9977         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9978         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9979         LDKReplyChannelRange msg_var = msg;
9980         uint32_t msg_ref = 0;
9981         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9982         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9983         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9984         msg_ref = (uintptr_t)msg_var.inner;
9985         if (msg_var.is_owned) {
9986                 msg_ref |= 1;
9987         }
9988         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 79, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9989         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9990         CHECK_ACCESS(ret_ptr);
9991         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9992         FREE((void*)ret);
9993         return ret_conv;
9994 }
9995 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9996         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9997         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9998         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9999         LDKReplyShortChannelIdsEnd msg_var = msg;
10000         uint32_t msg_ref = 0;
10001         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10002         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10003         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10004         msg_ref = (uintptr_t)msg_var.inner;
10005         if (msg_var.is_owned) {
10006                 msg_ref |= 1;
10007         }
10008         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10009         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10010         CHECK_ACCESS(ret_ptr);
10011         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10012         FREE((void*)ret);
10013         return ret_conv;
10014 }
10015 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10016         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10017         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10018         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10019         LDKQueryChannelRange msg_var = msg;
10020         uint32_t msg_ref = 0;
10021         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10022         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10024         msg_ref = (uintptr_t)msg_var.inner;
10025         if (msg_var.is_owned) {
10026                 msg_ref |= 1;
10027         }
10028         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10029         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10030         CHECK_ACCESS(ret_ptr);
10031         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10032         FREE((void*)ret);
10033         return ret_conv;
10034 }
10035 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10036         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10037         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10038         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10039         LDKQueryShortChannelIds msg_var = msg;
10040         uint32_t msg_ref = 0;
10041         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10042         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10043         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10044         msg_ref = (uintptr_t)msg_var.inner;
10045         if (msg_var.is_owned) {
10046                 msg_ref |= 1;
10047         }
10048         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 82, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10049         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10050         CHECK_ACCESS(ret_ptr);
10051         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10052         FREE((void*)ret);
10053         return ret_conv;
10054 }
10055 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10056         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10057         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10058         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10059 }
10060 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
10061         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10062         atomic_init(&calls->refcnt, 1);
10063         calls->instance_ptr = o;
10064
10065         LDKRoutingMessageHandler ret = {
10066                 .this_arg = (void*) calls,
10067                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10068                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10069                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10070                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10071                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10072                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
10073                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10074                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10075                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10076                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10077                 .free = LDKRoutingMessageHandler_JCalls_free,
10078                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
10079         };
10080         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10081         return ret;
10082 }
10083 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
10084         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10085         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
10086         return (long)res_ptr;
10087 }
10088 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
10089         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10090         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10091         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10092         LDKNodeAnnouncement msg_conv;
10093         msg_conv.inner = (void*)(msg & (~1));
10094         msg_conv.is_owned = false;
10095         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10096         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10097         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10098         return (uint32_t)ret_conv;
10099 }
10100
10101 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
10102         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10103         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10104         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10105         LDKChannelAnnouncement msg_conv;
10106         msg_conv.inner = (void*)(msg & (~1));
10107         msg_conv.is_owned = false;
10108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10109         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10110         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10111         return (uint32_t)ret_conv;
10112 }
10113
10114 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10115         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10116         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10117         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10118         LDKChannelUpdate msg_conv;
10119         msg_conv.inner = (void*)(msg & (~1));
10120         msg_conv.is_owned = false;
10121         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10122         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10123         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10124         return (uint32_t)ret_conv;
10125 }
10126
10127 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) {
10128         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10129         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10130         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10131         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10132         uint32_tArray ret_arr = NULL;
10133         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10134         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10135         for (size_t h = 0; h < ret_var.datalen; h++) {
10136                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10137                 *ret_conv_59_conv = ret_var.data[h];
10138                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10139         }
10140         
10141         FREE(ret_var.data);
10142         return ret_arr;
10143 }
10144
10145 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) {
10146         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10147         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10148         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10149         LDKPublicKey starting_point_ref;
10150         CHECK(starting_point->arr_len == 33);
10151         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10152         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10153         uint32_tArray ret_arr = NULL;
10154         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10155         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10156         for (size_t s = 0; s < ret_var.datalen; s++) {
10157                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10158                 uint32_t ret_conv_18_ref = 0;
10159                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10160                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10161                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10162                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10163                 if (ret_conv_18_var.is_owned) {
10164                         ret_conv_18_ref |= 1;
10165                 }
10166                 ret_arr_ptr[s] = ret_conv_18_ref;
10167         }
10168         
10169         FREE(ret_var.data);
10170         return ret_arr;
10171 }
10172
10173 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10174         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10175         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10176         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10177         LDKPublicKey their_node_id_ref;
10178         CHECK(their_node_id->arr_len == 33);
10179         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10180         LDKInit init_conv;
10181         init_conv.inner = (void*)(init & (~1));
10182         init_conv.is_owned = false;
10183         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10184         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10185 }
10186
10187 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) {
10188         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10189         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10190         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10191         LDKPublicKey their_node_id_ref;
10192         CHECK(their_node_id->arr_len == 33);
10193         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10194         LDKReplyChannelRange msg_conv;
10195         msg_conv.inner = (void*)(msg & (~1));
10196         msg_conv.is_owned = (msg & 1) || (msg == 0);
10197         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10198         msg_conv = ReplyChannelRange_clone(&msg_conv);
10199         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10200         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10201         return (uint32_t)ret_conv;
10202 }
10203
10204 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) {
10205         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10206         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10207         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10208         LDKPublicKey their_node_id_ref;
10209         CHECK(their_node_id->arr_len == 33);
10210         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10211         LDKReplyShortChannelIdsEnd msg_conv;
10212         msg_conv.inner = (void*)(msg & (~1));
10213         msg_conv.is_owned = (msg & 1) || (msg == 0);
10214         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10215         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10216         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10217         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10218         return (uint32_t)ret_conv;
10219 }
10220
10221 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) {
10222         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10224         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10225         LDKPublicKey their_node_id_ref;
10226         CHECK(their_node_id->arr_len == 33);
10227         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10228         LDKQueryChannelRange msg_conv;
10229         msg_conv.inner = (void*)(msg & (~1));
10230         msg_conv.is_owned = (msg & 1) || (msg == 0);
10231         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10232         msg_conv = QueryChannelRange_clone(&msg_conv);
10233         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10234         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10235         return (uint32_t)ret_conv;
10236 }
10237
10238 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) {
10239         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10240         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10241         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10242         LDKPublicKey their_node_id_ref;
10243         CHECK(their_node_id->arr_len == 33);
10244         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10245         LDKQueryShortChannelIds msg_conv;
10246         msg_conv.inner = (void*)(msg & (~1));
10247         msg_conv.is_owned = (msg & 1) || (msg == 0);
10248         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10249         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10250         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10251         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10252         return (uint32_t)ret_conv;
10253 }
10254
10255 typedef struct LDKCustomMessageReader_JCalls {
10256         atomic_size_t refcnt;
10257         uint32_t instance_ptr;
10258 } LDKCustomMessageReader_JCalls;
10259 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10260         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10261         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10262                 FREE(j_calls);
10263         }
10264 }
10265 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10266         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10267         int16_t message_type_conv = message_type;
10268         LDKu8slice buffer_var = buffer;
10269         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10270         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10271         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 83, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
10272         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10273         CHECK_ACCESS(ret_ptr);
10274         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10275         FREE((void*)ret);
10276         return ret_conv;
10277 }
10278 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10279         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10280         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10281 }
10282 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10283         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10284         atomic_init(&calls->refcnt, 1);
10285         calls->instance_ptr = o;
10286
10287         LDKCustomMessageReader ret = {
10288                 .this_arg = (void*) calls,
10289                 .read = read_LDKCustomMessageReader_jcall,
10290                 .free = LDKCustomMessageReader_JCalls_free,
10291         };
10292         return ret;
10293 }
10294 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10295         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10296         *res_ptr = LDKCustomMessageReader_init(o);
10297         return (long)res_ptr;
10298 }
10299 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10300         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10301         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10302         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10303         LDKu8slice buffer_ref;
10304         buffer_ref.datalen = buffer->arr_len;
10305         buffer_ref.data = buffer->elems;
10306         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10307         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10308         FREE(buffer);
10309         return (uint32_t)ret_conv;
10310 }
10311
10312 typedef struct LDKCustomMessageHandler_JCalls {
10313         atomic_size_t refcnt;
10314         uint32_t instance_ptr;
10315         LDKCustomMessageReader_JCalls* CustomMessageReader;
10316 } LDKCustomMessageHandler_JCalls;
10317 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10318         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10319         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10320                 FREE(j_calls);
10321         }
10322 }
10323 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10324         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10325         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10326         *msg_ret = msg;
10327         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10328         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10329         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 84, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
10330         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10331         CHECK_ACCESS(ret_ptr);
10332         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10333         FREE((void*)ret);
10334         return ret_conv;
10335 }
10336 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10337         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10338         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 85);
10339         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10340         ret_constr.datalen = ret->arr_len;
10341         if (ret_constr.datalen > 0)
10342                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10343         else
10344                 ret_constr.data = NULL;
10345         uint32_t* ret_vals = ret->elems;
10346         for (size_t z = 0; z < ret_constr.datalen; z++) {
10347                 uint32_t ret_conv_25 = ret_vals[z];
10348                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10349                 CHECK_ACCESS(ret_conv_25_ptr);
10350                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10351                 FREE((void*)ret_conv_25);
10352                 ret_constr.data[z] = ret_conv_25_conv;
10353         }
10354         FREE(ret);
10355         return ret_constr;
10356 }
10357 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10358         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10359         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10360         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10361 }
10362 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10363         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10364         atomic_init(&calls->refcnt, 1);
10365         calls->instance_ptr = o;
10366
10367         LDKCustomMessageHandler ret = {
10368                 .this_arg = (void*) calls,
10369                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10370                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10371                 .free = LDKCustomMessageHandler_JCalls_free,
10372                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10373         };
10374         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10375         return ret;
10376 }
10377 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10378         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10379         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10380         return (long)res_ptr;
10381 }
10382 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) {
10383         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10384         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10385         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10386         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10387         CHECK_ACCESS(msg_ptr);
10388         LDKType msg_conv = *(LDKType*)(msg_ptr);
10389         if (msg_conv.free == LDKType_JCalls_free) {
10390                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10391                 LDKType_JCalls_cloned(&msg_conv);
10392         }
10393         LDKPublicKey sender_node_id_ref;
10394         CHECK(sender_node_id->arr_len == 33);
10395         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10396         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10397         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10398         return (uint32_t)ret_conv;
10399 }
10400
10401 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10402         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10403         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10404         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10405         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10406         uint32_tArray ret_arr = NULL;
10407         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10408         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10409         for (size_t z = 0; z < ret_var.datalen; z++) {
10410                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10411                 *ret_conv_25_conv = ret_var.data[z];
10412                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10413         }
10414         
10415         FREE(ret_var.data);
10416         return ret_arr;
10417 }
10418
10419 typedef struct LDKSocketDescriptor_JCalls {
10420         atomic_size_t refcnt;
10421         uint32_t instance_ptr;
10422 } LDKSocketDescriptor_JCalls;
10423 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10424         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10425         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10426                 FREE(j_calls);
10427         }
10428 }
10429 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10430         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10431         LDKu8slice data_var = data;
10432         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10433         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10434         jboolean resume_read_conv = resume_read;
10435         return js_invoke_function_u_uu(j_calls->instance_ptr, 86, (uint32_t)data_arr, (uint32_t)resume_read_conv);
10436 }
10437 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10438         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10439         js_invoke_function_u_(j_calls->instance_ptr, 87);
10440 }
10441 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10442         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10443         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10444         *other_arg_clone = SocketDescriptor_clone(other_arg);
10445         return js_invoke_function_u_u(j_calls->instance_ptr, 88, (uint32_t)(uint32_t)other_arg_clone);
10446 }
10447 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10448         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10449         return js_invoke_function_b_(j_calls->instance_ptr, 89);
10450 }
10451 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10452         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10453         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10454 }
10455 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10456         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10457         atomic_init(&calls->refcnt, 1);
10458         calls->instance_ptr = o;
10459
10460         LDKSocketDescriptor ret = {
10461                 .this_arg = (void*) calls,
10462                 .send_data = send_data_LDKSocketDescriptor_jcall,
10463                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10464                 .eq = eq_LDKSocketDescriptor_jcall,
10465                 .hash = hash_LDKSocketDescriptor_jcall,
10466                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10467                 .free = LDKSocketDescriptor_JCalls_free,
10468         };
10469         return ret;
10470 }
10471 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10472         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10473         *res_ptr = LDKSocketDescriptor_init(o);
10474         return (long)res_ptr;
10475 }
10476 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10477         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10478         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10479         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10480         LDKu8slice data_ref;
10481         data_ref.datalen = data->arr_len;
10482         data_ref.data = data->elems;
10483         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10484         FREE(data);
10485         return ret_conv;
10486 }
10487
10488 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10489         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10490         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10491         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10492         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10493 }
10494
10495 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10496         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10497         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10498         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10499         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10500         return ret_conv;
10501 }
10502
10503 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10504         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10505         switch(obj->tag) {
10506                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10507                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10508                 case LDKEffectiveCapacity_Total: return 2;
10509                 case LDKEffectiveCapacity_Infinite: return 3;
10510                 case LDKEffectiveCapacity_Unknown: return 4;
10511                 default: abort();
10512         }
10513 }
10514 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10515         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10516         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10517                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10518         return liquidity_msat_conv;
10519 }
10520 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10521         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10522         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10523                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10524         return amount_msat_conv;
10525 }
10526 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10527         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10528         assert(obj->tag == LDKEffectiveCapacity_Total);
10529                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10530         return capacity_msat_conv;
10531 }
10532 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint32_t ptr) {
10533         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10534         assert(obj->tag == LDKEffectiveCapacity_Total);
10535                         uint32_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
10536         return htlc_maximum_msat_ref;
10537 }
10538 typedef struct LDKLockableScore_JCalls {
10539         atomic_size_t refcnt;
10540         uint32_t instance_ptr;
10541 } LDKLockableScore_JCalls;
10542 static void LDKLockableScore_JCalls_free(void* this_arg) {
10543         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10544         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10545                 FREE(j_calls);
10546         }
10547 }
10548 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10549         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10550         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 90);
10551         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10552         CHECK_ACCESS(ret_ptr);
10553         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10554         if (ret_conv.free == LDKScore_JCalls_free) {
10555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10556                 LDKScore_JCalls_cloned(&ret_conv);
10557         }// WARNING: we may need a move here but no clone is available for LDKScore
10558         
10559         return ret_conv;
10560 }
10561 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10562         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10563         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10564 }
10565 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10566         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10567         atomic_init(&calls->refcnt, 1);
10568         calls->instance_ptr = o;
10569
10570         LDKLockableScore ret = {
10571                 .this_arg = (void*) calls,
10572                 .lock = lock_LDKLockableScore_jcall,
10573                 .free = LDKLockableScore_JCalls_free,
10574         };
10575         return ret;
10576 }
10577 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10578         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10579         *res_ptr = LDKLockableScore_init(o);
10580         return (long)res_ptr;
10581 }
10582 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10583         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10584         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10585         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10586         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10587         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10588         return (uint32_t)ret_ret;
10589 }
10590
10591 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10592         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10593         switch(obj->tag) {
10594                 case LDKFallback_SegWitProgram: return 0;
10595                 case LDKFallback_PubKeyHash: return 1;
10596                 case LDKFallback_ScriptHash: return 2;
10597                 default: abort();
10598         }
10599 }
10600 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10601         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10602         assert(obj->tag == LDKFallback_SegWitProgram);
10603                         uint8_t version_val = obj->seg_wit_program.version._0;
10604         return version_val;
10605 }
10606 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10607         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10608         assert(obj->tag == LDKFallback_SegWitProgram);
10609                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10610                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10611                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10612         return program_arr;
10613 }
10614 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10615         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10616         assert(obj->tag == LDKFallback_PubKeyHash);
10617                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10618                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10619         return pub_key_hash_arr;
10620 }
10621 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10622         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10623         assert(obj->tag == LDKFallback_ScriptHash);
10624                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10625                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10626         return script_hash_arr;
10627 }
10628 typedef struct LDKPayer_JCalls {
10629         atomic_size_t refcnt;
10630         uint32_t instance_ptr;
10631 } LDKPayer_JCalls;
10632 static void LDKPayer_JCalls_free(void* this_arg) {
10633         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10634         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10635                 FREE(j_calls);
10636         }
10637 }
10638 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10639         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10640         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 91);
10641         LDKPublicKey ret_ref;
10642         CHECK(ret->arr_len == 33);
10643         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10644         return ret_ref;
10645 }
10646 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10647         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10648         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 92);
10649         LDKCVec_ChannelDetailsZ ret_constr;
10650         ret_constr.datalen = ret->arr_len;
10651         if (ret_constr.datalen > 0)
10652                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10653         else
10654                 ret_constr.data = NULL;
10655         uint32_t* ret_vals = ret->elems;
10656         for (size_t q = 0; q < ret_constr.datalen; q++) {
10657                 uint32_t ret_conv_16 = ret_vals[q];
10658                 LDKChannelDetails ret_conv_16_conv;
10659                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10660                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10661                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10662                 ret_constr.data[q] = ret_conv_16_conv;
10663         }
10664         FREE(ret);
10665         return ret_constr;
10666 }
10667 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10668         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10669         LDKRoute route_var = *route;
10670         uint32_t route_ref = 0;
10671         route_var = Route_clone(&route_var);
10672         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10673         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10674         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10675         route_ref = (uintptr_t)route_var.inner;
10676         if (route_var.is_owned) {
10677                 route_ref |= 1;
10678         }
10679         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10680         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10681         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10682         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10683         uint32_t ret = js_invoke_function_u_uuu(j_calls->instance_ptr, 93, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr);
10684         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10685         CHECK_ACCESS(ret_ptr);
10686         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10687         FREE((void*)ret);
10688         return ret_conv;
10689 }
10690 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10691         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10692         LDKRoute route_var = *route;
10693         uint32_t route_ref = 0;
10694         route_var = Route_clone(&route_var);
10695         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10696         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10697         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10698         route_ref = (uintptr_t)route_var.inner;
10699         if (route_var.is_owned) {
10700                 route_ref |= 1;
10701         }
10702         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10703         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10704         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 94, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10705         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10706         CHECK_ACCESS(ret_ptr);
10707         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10708         FREE((void*)ret);
10709         return ret_conv;
10710 }
10711 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10712         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10713         LDKRoute route_var = *route;
10714         uint32_t route_ref = 0;
10715         route_var = Route_clone(&route_var);
10716         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10717         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10718         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10719         route_ref = (uintptr_t)route_var.inner;
10720         if (route_var.is_owned) {
10721                 route_ref |= 1;
10722         }
10723         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10724         memcpy(payment_id_arr->elems, payment_id.data, 32);
10725         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 95, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10726         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10727         CHECK_ACCESS(ret_ptr);
10728         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10729         FREE((void*)ret);
10730         return ret_conv;
10731 }
10732 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10733         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10734         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10735         memcpy(payment_id_arr->elems, payment_id.data, 32);
10736         js_invoke_function_u_u(j_calls->instance_ptr, 96, (uint32_t)payment_id_arr);
10737 }
10738 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10739         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10740         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10741 }
10742 static inline LDKPayer LDKPayer_init (JSValue o) {
10743         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10744         atomic_init(&calls->refcnt, 1);
10745         calls->instance_ptr = o;
10746
10747         LDKPayer ret = {
10748                 .this_arg = (void*) calls,
10749                 .node_id = node_id_LDKPayer_jcall,
10750                 .first_hops = first_hops_LDKPayer_jcall,
10751                 .send_payment = send_payment_LDKPayer_jcall,
10752                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10753                 .retry_payment = retry_payment_LDKPayer_jcall,
10754                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10755                 .free = LDKPayer_JCalls_free,
10756         };
10757         return ret;
10758 }
10759 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10760         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10761         *res_ptr = LDKPayer_init(o);
10762         return (long)res_ptr;
10763 }
10764 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10767         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10768         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10769         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10770         return ret_arr;
10771 }
10772
10773 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10774         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10775         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10776         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10777         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10778         uint32_tArray ret_arr = NULL;
10779         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10780         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10781         for (size_t q = 0; q < ret_var.datalen; q++) {
10782                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10783                 uint32_t ret_conv_16_ref = 0;
10784                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10785                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10786                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10787                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10788                 if (ret_conv_16_var.is_owned) {
10789                         ret_conv_16_ref |= 1;
10790                 }
10791                 ret_arr_ptr[q] = ret_conv_16_ref;
10792         }
10793         
10794         FREE(ret_var.data);
10795         return ret_arr;
10796 }
10797
10798 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) {
10799         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10800         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10801         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10802         LDKRoute route_conv;
10803         route_conv.inner = (void*)(route & (~1));
10804         route_conv.is_owned = false;
10805         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10806         LDKThirtyTwoBytes payment_hash_ref;
10807         CHECK(payment_hash->arr_len == 32);
10808         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10809         LDKThirtyTwoBytes payment_secret_ref;
10810         CHECK(payment_secret->arr_len == 32);
10811         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10812         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10813         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10814         return (uint32_t)ret_conv;
10815 }
10816
10817 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) {
10818         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10819         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10820         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10821         LDKRoute route_conv;
10822         route_conv.inner = (void*)(route & (~1));
10823         route_conv.is_owned = false;
10824         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10825         LDKThirtyTwoBytes payment_preimage_ref;
10826         CHECK(payment_preimage->arr_len == 32);
10827         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10828         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10829         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10830         return (uint32_t)ret_conv;
10831 }
10832
10833 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10834         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10835         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10836         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10837         LDKRoute route_conv;
10838         route_conv.inner = (void*)(route & (~1));
10839         route_conv.is_owned = false;
10840         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10841         LDKThirtyTwoBytes payment_id_ref;
10842         CHECK(payment_id->arr_len == 32);
10843         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10844         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10845         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10846         return (uint32_t)ret_conv;
10847 }
10848
10849 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10850         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10851         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10852         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10853         LDKThirtyTwoBytes payment_id_ref;
10854         CHECK(payment_id->arr_len == 32);
10855         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10856         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10857 }
10858
10859 typedef struct LDKRouter_JCalls {
10860         atomic_size_t refcnt;
10861         uint32_t instance_ptr;
10862 } LDKRouter_JCalls;
10863 static void LDKRouter_JCalls_free(void* this_arg) {
10864         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10865         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10866                 FREE(j_calls);
10867         }
10868 }
10869 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) {
10870         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10871         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10872         memcpy(payer_arr->elems, payer.compressed_form, 33);
10873         LDKRouteParameters route_params_var = *route_params;
10874         uint32_t route_params_ref = 0;
10875         route_params_var = RouteParameters_clone(&route_params_var);
10876         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10877         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10878         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10879         route_params_ref = (uintptr_t)route_params_var.inner;
10880         if (route_params_var.is_owned) {
10881                 route_params_ref |= 1;
10882         }
10883         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10884         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10885         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10886         uint32_tArray first_hops_arr = NULL;
10887         if (first_hops != NULL) {
10888                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10889                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10890                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10891                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10892                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10893                         uint32_t first_hops_conv_16_ref = 0;
10894                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10895                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10896                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10897                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10898                         if (first_hops_conv_16_var.is_owned) {
10899                                 first_hops_conv_16_ref |= 1;
10900                         }
10901                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10902                 }
10903         
10904         }
10905         // WARNING: This object doesn't live past this scope, needs clone!
10906         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10907         uint32_t ret = js_invoke_function_u_uuuuu(j_calls->instance_ptr, 97, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer);
10908         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10909         CHECK_ACCESS(ret_ptr);
10910         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10911         FREE((void*)ret);
10912         return ret_conv;
10913 }
10914 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10915         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10916         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10917 }
10918 static inline LDKRouter LDKRouter_init (JSValue o) {
10919         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10920         atomic_init(&calls->refcnt, 1);
10921         calls->instance_ptr = o;
10922
10923         LDKRouter ret = {
10924                 .this_arg = (void*) calls,
10925                 .find_route = find_route_LDKRouter_jcall,
10926                 .free = LDKRouter_JCalls_free,
10927         };
10928         return ret;
10929 }
10930 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10931         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10932         *res_ptr = LDKRouter_init(o);
10933         return (long)res_ptr;
10934 }
10935 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) {
10936         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10937         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10938         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10939         LDKPublicKey payer_ref;
10940         CHECK(payer->arr_len == 33);
10941         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10942         LDKRouteParameters route_params_conv;
10943         route_params_conv.inner = (void*)(route_params & (~1));
10944         route_params_conv.is_owned = false;
10945         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10946         unsigned char payment_hash_arr[32];
10947         CHECK(payment_hash->arr_len == 32);
10948         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10949         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10950         LDKCVec_ChannelDetailsZ first_hops_constr;
10951         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10952         if (first_hops != 0) {
10953                 first_hops_constr.datalen = first_hops->arr_len;
10954                 if (first_hops_constr.datalen > 0)
10955                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10956                 else
10957                         first_hops_constr.data = NULL;
10958                 uint32_t* first_hops_vals = first_hops->elems;
10959                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10960                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10961                         LDKChannelDetails first_hops_conv_16_conv;
10962                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10963                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10964                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10965                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10966                 }
10967                 FREE(first_hops);
10968                 first_hops_ptr = &first_hops_constr;
10969         }
10970         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10971         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10972         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10973         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10974         *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);
10975         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10976         return (uint32_t)ret_conv;
10977 }
10978
10979 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
10980         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10981         switch(obj->tag) {
10982                 case LDKRetry_Attempts: return 0;
10983                 default: abort();
10984         }
10985 }
10986 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
10987         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10988         assert(obj->tag == LDKRetry_Attempts);
10989                         uint32_t attempts_conv = obj->attempts;
10990         return attempts_conv;
10991 }
10992 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10993         LDKStr ret_str = _ldk_get_compiled_version();
10994         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10995         Str_free(ret_str);
10996         return ret_conv;
10997 }
10998
10999 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11000         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11001         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11002         Str_free(ret_str);
11003         return ret_conv;
11004 }
11005
11006 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11007         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11008         *ret_copy = Bech32Error_clone(arg);
11009 uint32_t ret_ref = (uintptr_t)ret_copy;
11010         return ret_ref;
11011 }
11012 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
11013         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
11014         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11015         return ret_conv;
11016 }
11017
11018 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
11019         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
11020         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11021         *ret_copy = Bech32Error_clone(orig_conv);
11022         uint32_t ret_ref = (uintptr_t)ret_copy;
11023         return ret_ref;
11024 }
11025
11026 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
11027         if ((o & 1) != 0) return;
11028         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11029         CHECK_ACCESS(o_ptr);
11030         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11031         FREE((void*)o);
11032         Bech32Error_free(o_conv);
11033 }
11034
11035 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11036         LDKTransaction _res_ref;
11037         _res_ref.datalen = _res->arr_len;
11038         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11039         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11040         _res_ref.data_is_owned = true;
11041         Transaction_free(_res_ref);
11042 }
11043
11044 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11045         LDKCVec_u8Z script_pubkey_ref;
11046         script_pubkey_ref.datalen = script_pubkey->arr_len;
11047         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11048         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11049         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11050         *ret_ref = TxOut_new(script_pubkey_ref, value);
11051         return (uint32_t)ret_ref;
11052 }
11053
11054 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
11055         if ((_res & 1) != 0) return;
11056         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11057         CHECK_ACCESS(_res_ptr);
11058         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11059         FREE((void*)_res);
11060         TxOut_free(_res_conv);
11061 }
11062
11063 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11064         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11065         *ret_ref = TxOut_clone(arg);
11066         return (uint32_t)ret_ref;
11067 }
11068 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
11069         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11070         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
11071         return ret_conv;
11072 }
11073
11074 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
11075         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11076         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11077         *ret_ref = TxOut_clone(orig_conv);
11078         return (uint32_t)ret_ref;
11079 }
11080
11081 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11082         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11083         Str_free(dummy);
11084 }
11085
11086 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11087         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11088         *ret_conv = CResult_NoneNoneZ_ok();
11089         return (uint32_t)ret_conv;
11090 }
11091
11092 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11093         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11094         *ret_conv = CResult_NoneNoneZ_err();
11095         return (uint32_t)ret_conv;
11096 }
11097
11098 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
11099         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
11100         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11101         return ret_conv;
11102 }
11103
11104 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
11105         if ((_res & 1) != 0) return;
11106         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11107         CHECK_ACCESS(_res_ptr);
11108         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11109         FREE((void*)_res);
11110         CResult_NoneNoneZ_free(_res_conv);
11111 }
11112
11113 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11114         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11115         *ret_conv = CResult_NoneNoneZ_clone(arg);
11116         return (uint32_t)ret_conv;
11117 }
11118 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11119         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11120         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11121         return ret_conv;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11125         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11126         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11127         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11128         return (uint32_t)ret_conv;
11129 }
11130
11131 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11132         LDKCounterpartyCommitmentSecrets o_conv;
11133         o_conv.inner = (void*)(o & (~1));
11134         o_conv.is_owned = (o & 1) || (o == 0);
11135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11136         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11137         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11138         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11139         return (uint32_t)ret_conv;
11140 }
11141
11142 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11143         LDKDecodeError e_conv;
11144         e_conv.inner = (void*)(e & (~1));
11145         e_conv.is_owned = (e & 1) || (e == 0);
11146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11147         e_conv = DecodeError_clone(&e_conv);
11148         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11149         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11150         return (uint32_t)ret_conv;
11151 }
11152
11153 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11154         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11155         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11156         return ret_conv;
11157 }
11158
11159 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11160         if ((_res & 1) != 0) return;
11161         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11162         CHECK_ACCESS(_res_ptr);
11163         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11164         FREE((void*)_res);
11165         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11166 }
11167
11168 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11169         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11170         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11171         return (uint32_t)ret_conv;
11172 }
11173 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11174         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11175         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11176         return ret_conv;
11177 }
11178
11179 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11180         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11181         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11182         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11183         return (uint32_t)ret_conv;
11184 }
11185
11186 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11187         LDKSecretKey o_ref;
11188         CHECK(o->arr_len == 32);
11189         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11190         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11191         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11192         return (uint32_t)ret_conv;
11193 }
11194
11195 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11196         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11197         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11198         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11199         return (uint32_t)ret_conv;
11200 }
11201
11202 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11203         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11204         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11205         return ret_conv;
11206 }
11207
11208 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11209         if ((_res & 1) != 0) return;
11210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11211         CHECK_ACCESS(_res_ptr);
11212         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11213         FREE((void*)_res);
11214         CResult_SecretKeyErrorZ_free(_res_conv);
11215 }
11216
11217 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11218         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11219         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11220         return (uint32_t)ret_conv;
11221 }
11222 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11223         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11224         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11225         return ret_conv;
11226 }
11227
11228 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11229         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11230         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11231         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11232         return (uint32_t)ret_conv;
11233 }
11234
11235 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11236         LDKPublicKey o_ref;
11237         CHECK(o->arr_len == 33);
11238         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11239         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11240         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11241         return (uint32_t)ret_conv;
11242 }
11243
11244 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11245         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11246         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11247         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11248         return (uint32_t)ret_conv;
11249 }
11250
11251 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11252         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11253         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11254         return ret_conv;
11255 }
11256
11257 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11258         if ((_res & 1) != 0) return;
11259         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11260         CHECK_ACCESS(_res_ptr);
11261         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11262         FREE((void*)_res);
11263         CResult_PublicKeyErrorZ_free(_res_conv);
11264 }
11265
11266 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11267         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11268         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11269         return (uint32_t)ret_conv;
11270 }
11271 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11272         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11273         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11274         return ret_conv;
11275 }
11276
11277 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11278         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11279         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11280         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11281         return (uint32_t)ret_conv;
11282 }
11283
11284 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11285         LDKTxCreationKeys o_conv;
11286         o_conv.inner = (void*)(o & (~1));
11287         o_conv.is_owned = (o & 1) || (o == 0);
11288         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11289         o_conv = TxCreationKeys_clone(&o_conv);
11290         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11291         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11292         return (uint32_t)ret_conv;
11293 }
11294
11295 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11296         LDKDecodeError e_conv;
11297         e_conv.inner = (void*)(e & (~1));
11298         e_conv.is_owned = (e & 1) || (e == 0);
11299         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11300         e_conv = DecodeError_clone(&e_conv);
11301         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11302         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11303         return (uint32_t)ret_conv;
11304 }
11305
11306 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11307         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11308         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11309         return ret_conv;
11310 }
11311
11312 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11313         if ((_res & 1) != 0) return;
11314         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11315         CHECK_ACCESS(_res_ptr);
11316         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11317         FREE((void*)_res);
11318         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11319 }
11320
11321 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11322         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11323         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11324         return (uint32_t)ret_conv;
11325 }
11326 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11327         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11328         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11329         return ret_conv;
11330 }
11331
11332 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11333         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11334         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11335         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11336         return (uint32_t)ret_conv;
11337 }
11338
11339 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11340         LDKChannelPublicKeys o_conv;
11341         o_conv.inner = (void*)(o & (~1));
11342         o_conv.is_owned = (o & 1) || (o == 0);
11343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11344         o_conv = ChannelPublicKeys_clone(&o_conv);
11345         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11346         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11347         return (uint32_t)ret_conv;
11348 }
11349
11350 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11351         LDKDecodeError e_conv;
11352         e_conv.inner = (void*)(e & (~1));
11353         e_conv.is_owned = (e & 1) || (e == 0);
11354         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11355         e_conv = DecodeError_clone(&e_conv);
11356         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11357         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11358         return (uint32_t)ret_conv;
11359 }
11360
11361 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11362         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11363         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11364         return ret_conv;
11365 }
11366
11367 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11368         if ((_res & 1) != 0) return;
11369         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11370         CHECK_ACCESS(_res_ptr);
11371         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11372         FREE((void*)_res);
11373         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11374 }
11375
11376 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11377         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11378         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11379         return (uint32_t)ret_conv;
11380 }
11381 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11382         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11383         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11384         return ret_conv;
11385 }
11386
11387 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11388         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11389         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11390         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11391         return (uint32_t)ret_conv;
11392 }
11393
11394 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11395         LDKTxCreationKeys o_conv;
11396         o_conv.inner = (void*)(o & (~1));
11397         o_conv.is_owned = (o & 1) || (o == 0);
11398         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11399         o_conv = TxCreationKeys_clone(&o_conv);
11400         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11401         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11402         return (uint32_t)ret_conv;
11403 }
11404
11405 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11406         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11407         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11408         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11409         return (uint32_t)ret_conv;
11410 }
11411
11412 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11413         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11414         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11415         return ret_conv;
11416 }
11417
11418 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11419         if ((_res & 1) != 0) return;
11420         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11421         CHECK_ACCESS(_res_ptr);
11422         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11423         FREE((void*)_res);
11424         CResult_TxCreationKeysErrorZ_free(_res_conv);
11425 }
11426
11427 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11428         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11429         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11430         return (uint32_t)ret_conv;
11431 }
11432 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11433         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11434         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11435         return ret_conv;
11436 }
11437
11438 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11439         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11440         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11441         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11442         return (uint32_t)ret_conv;
11443 }
11444
11445 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11446         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11447         *ret_copy = COption_u32Z_some(o);
11448         uint32_t ret_ref = (uintptr_t)ret_copy;
11449         return ret_ref;
11450 }
11451
11452 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11453         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11454         *ret_copy = COption_u32Z_none();
11455         uint32_t ret_ref = (uintptr_t)ret_copy;
11456         return ret_ref;
11457 }
11458
11459 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11460         if ((_res & 1) != 0) return;
11461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11462         CHECK_ACCESS(_res_ptr);
11463         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11464         FREE((void*)_res);
11465         COption_u32Z_free(_res_conv);
11466 }
11467
11468 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11469         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11470         *ret_copy = COption_u32Z_clone(arg);
11471 uint32_t ret_ref = (uintptr_t)ret_copy;
11472         return ret_ref;
11473 }
11474 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11475         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11476         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11477         return ret_conv;
11478 }
11479
11480 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11481         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11482         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11483         *ret_copy = COption_u32Z_clone(orig_conv);
11484         uint32_t ret_ref = (uintptr_t)ret_copy;
11485         return ret_ref;
11486 }
11487
11488 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11489         LDKHTLCOutputInCommitment o_conv;
11490         o_conv.inner = (void*)(o & (~1));
11491         o_conv.is_owned = (o & 1) || (o == 0);
11492         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11493         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11494         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11495         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11496         return (uint32_t)ret_conv;
11497 }
11498
11499 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11500         LDKDecodeError e_conv;
11501         e_conv.inner = (void*)(e & (~1));
11502         e_conv.is_owned = (e & 1) || (e == 0);
11503         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11504         e_conv = DecodeError_clone(&e_conv);
11505         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11506         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11507         return (uint32_t)ret_conv;
11508 }
11509
11510 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11511         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11512         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11513         return ret_conv;
11514 }
11515
11516 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11517         if ((_res & 1) != 0) return;
11518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11519         CHECK_ACCESS(_res_ptr);
11520         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11521         FREE((void*)_res);
11522         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11523 }
11524
11525 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11526         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11527         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11528         return (uint32_t)ret_conv;
11529 }
11530 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11531         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11532         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11533         return ret_conv;
11534 }
11535
11536 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11537         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11538         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11539         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11540         return (uint32_t)ret_conv;
11541 }
11542
11543 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11544         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11545         return ret_conv;
11546 }
11547
11548 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11549         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11550         return ret_conv;
11551 }
11552
11553 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11554         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11555         COption_NoneZ_free(_res_conv);
11556 }
11557
11558 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11559         LDKCounterpartyChannelTransactionParameters o_conv;
11560         o_conv.inner = (void*)(o & (~1));
11561         o_conv.is_owned = (o & 1) || (o == 0);
11562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11563         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11564         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11565         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11566         return (uint32_t)ret_conv;
11567 }
11568
11569 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11570         LDKDecodeError e_conv;
11571         e_conv.inner = (void*)(e & (~1));
11572         e_conv.is_owned = (e & 1) || (e == 0);
11573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11574         e_conv = DecodeError_clone(&e_conv);
11575         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11576         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11577         return (uint32_t)ret_conv;
11578 }
11579
11580 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11581         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11582         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11583         return ret_conv;
11584 }
11585
11586 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11587         if ((_res & 1) != 0) return;
11588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11589         CHECK_ACCESS(_res_ptr);
11590         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11591         FREE((void*)_res);
11592         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11593 }
11594
11595 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11596         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11597         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11598         return (uint32_t)ret_conv;
11599 }
11600 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11601         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11602         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11603         return ret_conv;
11604 }
11605
11606 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11607         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11608         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11609         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11610         return (uint32_t)ret_conv;
11611 }
11612
11613 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11614         LDKChannelTransactionParameters o_conv;
11615         o_conv.inner = (void*)(o & (~1));
11616         o_conv.is_owned = (o & 1) || (o == 0);
11617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11618         o_conv = ChannelTransactionParameters_clone(&o_conv);
11619         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11620         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11621         return (uint32_t)ret_conv;
11622 }
11623
11624 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11625         LDKDecodeError e_conv;
11626         e_conv.inner = (void*)(e & (~1));
11627         e_conv.is_owned = (e & 1) || (e == 0);
11628         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11629         e_conv = DecodeError_clone(&e_conv);
11630         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11631         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11632         return (uint32_t)ret_conv;
11633 }
11634
11635 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11636         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11637         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11638         return ret_conv;
11639 }
11640
11641 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11642         if ((_res & 1) != 0) return;
11643         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11644         CHECK_ACCESS(_res_ptr);
11645         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11646         FREE((void*)_res);
11647         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11648 }
11649
11650 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11651         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11652         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11653         return (uint32_t)ret_conv;
11654 }
11655 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11656         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11657         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11658         return ret_conv;
11659 }
11660
11661 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11662         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11663         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11664         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11665         return (uint32_t)ret_conv;
11666 }
11667
11668 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11669         LDKCVec_SignatureZ _res_constr;
11670         _res_constr.datalen = _res->arr_len;
11671         if (_res_constr.datalen > 0)
11672                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11673         else
11674                 _res_constr.data = NULL;
11675         int8_tArray* _res_vals = (void*) _res->elems;
11676         for (size_t m = 0; m < _res_constr.datalen; m++) {
11677                 int8_tArray _res_conv_12 = _res_vals[m];
11678                 LDKSignature _res_conv_12_ref;
11679                 CHECK(_res_conv_12->arr_len == 64);
11680                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11681                 _res_constr.data[m] = _res_conv_12_ref;
11682         }
11683         FREE(_res);
11684         CVec_SignatureZ_free(_res_constr);
11685 }
11686
11687 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11688         LDKHolderCommitmentTransaction o_conv;
11689         o_conv.inner = (void*)(o & (~1));
11690         o_conv.is_owned = (o & 1) || (o == 0);
11691         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11692         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11693         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11694         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11695         return (uint32_t)ret_conv;
11696 }
11697
11698 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11699         LDKDecodeError e_conv;
11700         e_conv.inner = (void*)(e & (~1));
11701         e_conv.is_owned = (e & 1) || (e == 0);
11702         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11703         e_conv = DecodeError_clone(&e_conv);
11704         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11705         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11706         return (uint32_t)ret_conv;
11707 }
11708
11709 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11710         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11711         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11712         return ret_conv;
11713 }
11714
11715 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11716         if ((_res & 1) != 0) return;
11717         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11718         CHECK_ACCESS(_res_ptr);
11719         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11720         FREE((void*)_res);
11721         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11722 }
11723
11724 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11725         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11726         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11727         return (uint32_t)ret_conv;
11728 }
11729 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11730         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11731         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11732         return ret_conv;
11733 }
11734
11735 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11736         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11737         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11738         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11739         return (uint32_t)ret_conv;
11740 }
11741
11742 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11743         LDKBuiltCommitmentTransaction o_conv;
11744         o_conv.inner = (void*)(o & (~1));
11745         o_conv.is_owned = (o & 1) || (o == 0);
11746         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11747         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11748         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11749         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11750         return (uint32_t)ret_conv;
11751 }
11752
11753 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11754         LDKDecodeError e_conv;
11755         e_conv.inner = (void*)(e & (~1));
11756         e_conv.is_owned = (e & 1) || (e == 0);
11757         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11758         e_conv = DecodeError_clone(&e_conv);
11759         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11760         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11761         return (uint32_t)ret_conv;
11762 }
11763
11764 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11765         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11766         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11767         return ret_conv;
11768 }
11769
11770 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11771         if ((_res & 1) != 0) return;
11772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11773         CHECK_ACCESS(_res_ptr);
11774         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11775         FREE((void*)_res);
11776         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11777 }
11778
11779 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11780         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11781         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11782         return (uint32_t)ret_conv;
11783 }
11784 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11785         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11786         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11787         return ret_conv;
11788 }
11789
11790 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11791         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11792         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11793         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11794         return (uint32_t)ret_conv;
11795 }
11796
11797 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11798         LDKTrustedClosingTransaction o_conv;
11799         o_conv.inner = (void*)(o & (~1));
11800         o_conv.is_owned = (o & 1) || (o == 0);
11801         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11802         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11803         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11804         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11805         return (uint32_t)ret_conv;
11806 }
11807
11808 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11809         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11810         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11811         return (uint32_t)ret_conv;
11812 }
11813
11814 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11815         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11816         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11817         return ret_conv;
11818 }
11819
11820 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11821         if ((_res & 1) != 0) return;
11822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11823         CHECK_ACCESS(_res_ptr);
11824         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11825         FREE((void*)_res);
11826         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11827 }
11828
11829 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11830         LDKCommitmentTransaction o_conv;
11831         o_conv.inner = (void*)(o & (~1));
11832         o_conv.is_owned = (o & 1) || (o == 0);
11833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11834         o_conv = CommitmentTransaction_clone(&o_conv);
11835         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11836         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11837         return (uint32_t)ret_conv;
11838 }
11839
11840 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11841         LDKDecodeError e_conv;
11842         e_conv.inner = (void*)(e & (~1));
11843         e_conv.is_owned = (e & 1) || (e == 0);
11844         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11845         e_conv = DecodeError_clone(&e_conv);
11846         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11847         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11848         return (uint32_t)ret_conv;
11849 }
11850
11851 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11852         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11853         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11854         return ret_conv;
11855 }
11856
11857 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11858         if ((_res & 1) != 0) return;
11859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11860         CHECK_ACCESS(_res_ptr);
11861         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11862         FREE((void*)_res);
11863         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11864 }
11865
11866 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11867         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11868         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11869         return (uint32_t)ret_conv;
11870 }
11871 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11872         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11873         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11874         return ret_conv;
11875 }
11876
11877 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11878         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11879         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11880         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11881         return (uint32_t)ret_conv;
11882 }
11883
11884 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11885         LDKTrustedCommitmentTransaction o_conv;
11886         o_conv.inner = (void*)(o & (~1));
11887         o_conv.is_owned = (o & 1) || (o == 0);
11888         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11889         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11890         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11891         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11892         return (uint32_t)ret_conv;
11893 }
11894
11895 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11896         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11897         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11898         return (uint32_t)ret_conv;
11899 }
11900
11901 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11902         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11903         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11904         return ret_conv;
11905 }
11906
11907 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11908         if ((_res & 1) != 0) return;
11909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11910         CHECK_ACCESS(_res_ptr);
11911         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11912         FREE((void*)_res);
11913         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11914 }
11915
11916 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11917         LDKCVec_SignatureZ o_constr;
11918         o_constr.datalen = o->arr_len;
11919         if (o_constr.datalen > 0)
11920                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11921         else
11922                 o_constr.data = NULL;
11923         int8_tArray* o_vals = (void*) o->elems;
11924         for (size_t m = 0; m < o_constr.datalen; m++) {
11925                 int8_tArray o_conv_12 = o_vals[m];
11926                 LDKSignature o_conv_12_ref;
11927                 CHECK(o_conv_12->arr_len == 64);
11928                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11929                 o_constr.data[m] = o_conv_12_ref;
11930         }
11931         FREE(o);
11932         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11933         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11934         return (uint32_t)ret_conv;
11935 }
11936
11937 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11938         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11939         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11940         return (uint32_t)ret_conv;
11941 }
11942
11943 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11944         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11945         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11946         return ret_conv;
11947 }
11948
11949 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11950         if ((_res & 1) != 0) return;
11951         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11952         CHECK_ACCESS(_res_ptr);
11953         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11954         FREE((void*)_res);
11955         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11956 }
11957
11958 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11959         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11960         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11961         return (uint32_t)ret_conv;
11962 }
11963 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11964         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11965         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11966         return ret_conv;
11967 }
11968
11969 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11970         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11971         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11972         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11973         return (uint32_t)ret_conv;
11974 }
11975
11976 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11977         LDKShutdownScript o_conv;
11978         o_conv.inner = (void*)(o & (~1));
11979         o_conv.is_owned = (o & 1) || (o == 0);
11980         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11981         o_conv = ShutdownScript_clone(&o_conv);
11982         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11983         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11984         return (uint32_t)ret_conv;
11985 }
11986
11987 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11988         LDKDecodeError e_conv;
11989         e_conv.inner = (void*)(e & (~1));
11990         e_conv.is_owned = (e & 1) || (e == 0);
11991         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11992         e_conv = DecodeError_clone(&e_conv);
11993         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11994         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11995         return (uint32_t)ret_conv;
11996 }
11997
11998 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11999         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12000         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12001         return ret_conv;
12002 }
12003
12004 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
12005         if ((_res & 1) != 0) return;
12006         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12007         CHECK_ACCESS(_res_ptr);
12008         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12009         FREE((void*)_res);
12010         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12011 }
12012
12013 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12014         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12015         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12016         return (uint32_t)ret_conv;
12017 }
12018 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
12019         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12020         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12021         return ret_conv;
12022 }
12023
12024 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
12025         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12026         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12027         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12028         return (uint32_t)ret_conv;
12029 }
12030
12031 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
12032         LDKShutdownScript o_conv;
12033         o_conv.inner = (void*)(o & (~1));
12034         o_conv.is_owned = (o & 1) || (o == 0);
12035         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12036         o_conv = ShutdownScript_clone(&o_conv);
12037         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12038         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12039         return (uint32_t)ret_conv;
12040 }
12041
12042 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
12043         LDKInvalidShutdownScript e_conv;
12044         e_conv.inner = (void*)(e & (~1));
12045         e_conv.is_owned = (e & 1) || (e == 0);
12046         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12047         e_conv = InvalidShutdownScript_clone(&e_conv);
12048         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12049         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12050         return (uint32_t)ret_conv;
12051 }
12052
12053 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
12054         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12055         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12056         return ret_conv;
12057 }
12058
12059 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
12060         if ((_res & 1) != 0) return;
12061         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12062         CHECK_ACCESS(_res_ptr);
12063         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12064         FREE((void*)_res);
12065         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12066 }
12067
12068 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12069         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12070         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12071         return (uint32_t)ret_conv;
12072 }
12073 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
12074         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12075         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12076         return ret_conv;
12077 }
12078
12079 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
12080         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12081         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12082         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12083         return (uint32_t)ret_conv;
12084 }
12085
12086 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
12087         LDKRouteHop o_conv;
12088         o_conv.inner = (void*)(o & (~1));
12089         o_conv.is_owned = (o & 1) || (o == 0);
12090         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12091         o_conv = RouteHop_clone(&o_conv);
12092         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12093         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12094         return (uint32_t)ret_conv;
12095 }
12096
12097 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
12098         LDKDecodeError e_conv;
12099         e_conv.inner = (void*)(e & (~1));
12100         e_conv.is_owned = (e & 1) || (e == 0);
12101         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12102         e_conv = DecodeError_clone(&e_conv);
12103         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12104         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12105         return (uint32_t)ret_conv;
12106 }
12107
12108 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
12109         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12110         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12111         return ret_conv;
12112 }
12113
12114 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12115         if ((_res & 1) != 0) return;
12116         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12117         CHECK_ACCESS(_res_ptr);
12118         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12119         FREE((void*)_res);
12120         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12121 }
12122
12123 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12124         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12125         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12126         return (uint32_t)ret_conv;
12127 }
12128 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12129         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12130         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12131         return ret_conv;
12132 }
12133
12134 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12135         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12136         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12137         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12138         return (uint32_t)ret_conv;
12139 }
12140
12141 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12142         LDKCVec_RouteHopZ _res_constr;
12143         _res_constr.datalen = _res->arr_len;
12144         if (_res_constr.datalen > 0)
12145                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12146         else
12147                 _res_constr.data = NULL;
12148         uint32_t* _res_vals = _res->elems;
12149         for (size_t k = 0; k < _res_constr.datalen; k++) {
12150                 uint32_t _res_conv_10 = _res_vals[k];
12151                 LDKRouteHop _res_conv_10_conv;
12152                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12153                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12154                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12155                 _res_constr.data[k] = _res_conv_10_conv;
12156         }
12157         FREE(_res);
12158         CVec_RouteHopZ_free(_res_constr);
12159 }
12160
12161 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12162         LDKCVec_CVec_RouteHopZZ _res_constr;
12163         _res_constr.datalen = _res->arr_len;
12164         if (_res_constr.datalen > 0)
12165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12166         else
12167                 _res_constr.data = NULL;
12168         uint32_tArray* _res_vals = (void*) _res->elems;
12169         for (size_t m = 0; m < _res_constr.datalen; m++) {
12170                 uint32_tArray _res_conv_12 = _res_vals[m];
12171                 LDKCVec_RouteHopZ _res_conv_12_constr;
12172                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12173                 if (_res_conv_12_constr.datalen > 0)
12174                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12175                 else
12176                         _res_conv_12_constr.data = NULL;
12177                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
12178                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12179                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12180                         LDKRouteHop _res_conv_12_conv_10_conv;
12181                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12182                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12183                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12184                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12185                 }
12186                 FREE(_res_conv_12);
12187                 _res_constr.data[m] = _res_conv_12_constr;
12188         }
12189         FREE(_res);
12190         CVec_CVec_RouteHopZZ_free(_res_constr);
12191 }
12192
12193 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12194         LDKRoute o_conv;
12195         o_conv.inner = (void*)(o & (~1));
12196         o_conv.is_owned = (o & 1) || (o == 0);
12197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12198         o_conv = Route_clone(&o_conv);
12199         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12200         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12201         return (uint32_t)ret_conv;
12202 }
12203
12204 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12205         LDKDecodeError e_conv;
12206         e_conv.inner = (void*)(e & (~1));
12207         e_conv.is_owned = (e & 1) || (e == 0);
12208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12209         e_conv = DecodeError_clone(&e_conv);
12210         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12211         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12212         return (uint32_t)ret_conv;
12213 }
12214
12215 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12216         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12217         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12218         return ret_conv;
12219 }
12220
12221 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12222         if ((_res & 1) != 0) return;
12223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12224         CHECK_ACCESS(_res_ptr);
12225         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12226         FREE((void*)_res);
12227         CResult_RouteDecodeErrorZ_free(_res_conv);
12228 }
12229
12230 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12231         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12232         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12233         return (uint32_t)ret_conv;
12234 }
12235 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12236         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12237         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12238         return ret_conv;
12239 }
12240
12241 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12242         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12243         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12244         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12245         return (uint32_t)ret_conv;
12246 }
12247
12248 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12249         LDKRouteParameters o_conv;
12250         o_conv.inner = (void*)(o & (~1));
12251         o_conv.is_owned = (o & 1) || (o == 0);
12252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12253         o_conv = RouteParameters_clone(&o_conv);
12254         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12255         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12256         return (uint32_t)ret_conv;
12257 }
12258
12259 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12260         LDKDecodeError e_conv;
12261         e_conv.inner = (void*)(e & (~1));
12262         e_conv.is_owned = (e & 1) || (e == 0);
12263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12264         e_conv = DecodeError_clone(&e_conv);
12265         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12266         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12267         return (uint32_t)ret_conv;
12268 }
12269
12270 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12271         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12272         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12273         return ret_conv;
12274 }
12275
12276 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12277         if ((_res & 1) != 0) return;
12278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12279         CHECK_ACCESS(_res_ptr);
12280         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12281         FREE((void*)_res);
12282         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12283 }
12284
12285 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12286         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12287         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12288         return (uint32_t)ret_conv;
12289 }
12290 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12291         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12292         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12293         return ret_conv;
12294 }
12295
12296 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12297         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12298         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12299         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12300         return (uint32_t)ret_conv;
12301 }
12302
12303 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12304         LDKCVec_RouteHintZ _res_constr;
12305         _res_constr.datalen = _res->arr_len;
12306         if (_res_constr.datalen > 0)
12307                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12308         else
12309                 _res_constr.data = NULL;
12310         uint32_t* _res_vals = _res->elems;
12311         for (size_t l = 0; l < _res_constr.datalen; l++) {
12312                 uint32_t _res_conv_11 = _res_vals[l];
12313                 LDKRouteHint _res_conv_11_conv;
12314                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12315                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12316                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12317                 _res_constr.data[l] = _res_conv_11_conv;
12318         }
12319         FREE(_res);
12320         CVec_RouteHintZ_free(_res_constr);
12321 }
12322
12323 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12324         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12325         *ret_copy = COption_u64Z_some(o);
12326         uint32_t ret_ref = (uintptr_t)ret_copy;
12327         return ret_ref;
12328 }
12329
12330 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12331         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12332         *ret_copy = COption_u64Z_none();
12333         uint32_t ret_ref = (uintptr_t)ret_copy;
12334         return ret_ref;
12335 }
12336
12337 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12338         if ((_res & 1) != 0) return;
12339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12340         CHECK_ACCESS(_res_ptr);
12341         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12342         FREE((void*)_res);
12343         COption_u64Z_free(_res_conv);
12344 }
12345
12346 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12347         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12348         *ret_copy = COption_u64Z_clone(arg);
12349 uint32_t ret_ref = (uintptr_t)ret_copy;
12350         return ret_ref;
12351 }
12352 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12353         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12354         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12355         return ret_conv;
12356 }
12357
12358 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12359         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12360         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12361         *ret_copy = COption_u64Z_clone(orig_conv);
12362         uint32_t ret_ref = (uintptr_t)ret_copy;
12363         return ret_ref;
12364 }
12365
12366 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12367         LDKPaymentParameters o_conv;
12368         o_conv.inner = (void*)(o & (~1));
12369         o_conv.is_owned = (o & 1) || (o == 0);
12370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12371         o_conv = PaymentParameters_clone(&o_conv);
12372         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12373         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12374         return (uint32_t)ret_conv;
12375 }
12376
12377 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12378         LDKDecodeError e_conv;
12379         e_conv.inner = (void*)(e & (~1));
12380         e_conv.is_owned = (e & 1) || (e == 0);
12381         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12382         e_conv = DecodeError_clone(&e_conv);
12383         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12384         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12385         return (uint32_t)ret_conv;
12386 }
12387
12388 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12389         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12390         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12391         return ret_conv;
12392 }
12393
12394 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12395         if ((_res & 1) != 0) return;
12396         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12397         CHECK_ACCESS(_res_ptr);
12398         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12399         FREE((void*)_res);
12400         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12401 }
12402
12403 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12404         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12405         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12406         return (uint32_t)ret_conv;
12407 }
12408 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12409         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12410         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12411         return ret_conv;
12412 }
12413
12414 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12415         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12416         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12417         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12418         return (uint32_t)ret_conv;
12419 }
12420
12421 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12422         LDKCVec_RouteHintHopZ _res_constr;
12423         _res_constr.datalen = _res->arr_len;
12424         if (_res_constr.datalen > 0)
12425                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12426         else
12427                 _res_constr.data = NULL;
12428         uint32_t* _res_vals = _res->elems;
12429         for (size_t o = 0; o < _res_constr.datalen; o++) {
12430                 uint32_t _res_conv_14 = _res_vals[o];
12431                 LDKRouteHintHop _res_conv_14_conv;
12432                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12433                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12434                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12435                 _res_constr.data[o] = _res_conv_14_conv;
12436         }
12437         FREE(_res);
12438         CVec_RouteHintHopZ_free(_res_constr);
12439 }
12440
12441 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12442         LDKRouteHint o_conv;
12443         o_conv.inner = (void*)(o & (~1));
12444         o_conv.is_owned = (o & 1) || (o == 0);
12445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12446         o_conv = RouteHint_clone(&o_conv);
12447         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12448         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12449         return (uint32_t)ret_conv;
12450 }
12451
12452 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12453         LDKDecodeError e_conv;
12454         e_conv.inner = (void*)(e & (~1));
12455         e_conv.is_owned = (e & 1) || (e == 0);
12456         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12457         e_conv = DecodeError_clone(&e_conv);
12458         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12459         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12460         return (uint32_t)ret_conv;
12461 }
12462
12463 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12464         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12465         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12466         return ret_conv;
12467 }
12468
12469 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12470         if ((_res & 1) != 0) return;
12471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12472         CHECK_ACCESS(_res_ptr);
12473         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12474         FREE((void*)_res);
12475         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12476 }
12477
12478 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12479         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12480         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12481         return (uint32_t)ret_conv;
12482 }
12483 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12484         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12485         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12486         return ret_conv;
12487 }
12488
12489 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12490         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12491         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12492         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12493         return (uint32_t)ret_conv;
12494 }
12495
12496 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12497         LDKRouteHintHop o_conv;
12498         o_conv.inner = (void*)(o & (~1));
12499         o_conv.is_owned = (o & 1) || (o == 0);
12500         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12501         o_conv = RouteHintHop_clone(&o_conv);
12502         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12503         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12504         return (uint32_t)ret_conv;
12505 }
12506
12507 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12508         LDKDecodeError e_conv;
12509         e_conv.inner = (void*)(e & (~1));
12510         e_conv.is_owned = (e & 1) || (e == 0);
12511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12512         e_conv = DecodeError_clone(&e_conv);
12513         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12514         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12515         return (uint32_t)ret_conv;
12516 }
12517
12518 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12519         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12520         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12521         return ret_conv;
12522 }
12523
12524 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12525         if ((_res & 1) != 0) return;
12526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12527         CHECK_ACCESS(_res_ptr);
12528         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12529         FREE((void*)_res);
12530         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12531 }
12532
12533 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12534         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12535         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12536         return (uint32_t)ret_conv;
12537 }
12538 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12539         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12540         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12541         return ret_conv;
12542 }
12543
12544 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12545         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12546         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12547         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12548         return (uint32_t)ret_conv;
12549 }
12550
12551 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12552         LDKCVec_ChannelDetailsZ _res_constr;
12553         _res_constr.datalen = _res->arr_len;
12554         if (_res_constr.datalen > 0)
12555                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12556         else
12557                 _res_constr.data = NULL;
12558         uint32_t* _res_vals = _res->elems;
12559         for (size_t q = 0; q < _res_constr.datalen; q++) {
12560                 uint32_t _res_conv_16 = _res_vals[q];
12561                 LDKChannelDetails _res_conv_16_conv;
12562                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12563                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12564                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12565                 _res_constr.data[q] = _res_conv_16_conv;
12566         }
12567         FREE(_res);
12568         CVec_ChannelDetailsZ_free(_res_constr);
12569 }
12570
12571 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12572         LDKRoute o_conv;
12573         o_conv.inner = (void*)(o & (~1));
12574         o_conv.is_owned = (o & 1) || (o == 0);
12575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12576         o_conv = Route_clone(&o_conv);
12577         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12578         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12579         return (uint32_t)ret_conv;
12580 }
12581
12582 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12583         LDKLightningError e_conv;
12584         e_conv.inner = (void*)(e & (~1));
12585         e_conv.is_owned = (e & 1) || (e == 0);
12586         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12587         e_conv = LightningError_clone(&e_conv);
12588         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12589         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12590         return (uint32_t)ret_conv;
12591 }
12592
12593 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12594         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12595         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12596         return ret_conv;
12597 }
12598
12599 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12600         if ((_res & 1) != 0) return;
12601         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12602         CHECK_ACCESS(_res_ptr);
12603         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12604         FREE((void*)_res);
12605         CResult_RouteLightningErrorZ_free(_res_conv);
12606 }
12607
12608 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12609         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12610         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12611         return (uint32_t)ret_conv;
12612 }
12613 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12614         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12615         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12616         return ret_conv;
12617 }
12618
12619 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12620         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12621         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12622         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12623         return (uint32_t)ret_conv;
12624 }
12625
12626 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12627         LDKCVec_PublicKeyZ _res_constr;
12628         _res_constr.datalen = _res->arr_len;
12629         if (_res_constr.datalen > 0)
12630                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12631         else
12632                 _res_constr.data = NULL;
12633         int8_tArray* _res_vals = (void*) _res->elems;
12634         for (size_t m = 0; m < _res_constr.datalen; m++) {
12635                 int8_tArray _res_conv_12 = _res_vals[m];
12636                 LDKPublicKey _res_conv_12_ref;
12637                 CHECK(_res_conv_12->arr_len == 33);
12638                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12639                 _res_constr.data[m] = _res_conv_12_ref;
12640         }
12641         FREE(_res);
12642         CVec_PublicKeyZ_free(_res_constr);
12643 }
12644
12645 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12646         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12647         CHECK_ACCESS(o_ptr);
12648         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12649         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12650         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12651         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12652         return (uint32_t)ret_conv;
12653 }
12654
12655 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12656         LDKDecodeError e_conv;
12657         e_conv.inner = (void*)(e & (~1));
12658         e_conv.is_owned = (e & 1) || (e == 0);
12659         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12660         e_conv = DecodeError_clone(&e_conv);
12661         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12662         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12663         return (uint32_t)ret_conv;
12664 }
12665
12666 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12667         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12668         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12669         return ret_conv;
12670 }
12671
12672 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12673         if ((_res & 1) != 0) return;
12674         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12675         CHECK_ACCESS(_res_ptr);
12676         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12677         FREE((void*)_res);
12678         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12679 }
12680
12681 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12682         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12683         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12684         return (uint32_t)ret_conv;
12685 }
12686 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12687         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12688         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12689         return ret_conv;
12690 }
12691
12692 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
12693         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
12694         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12695         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
12696         return (uint32_t)ret_conv;
12697 }
12698
12699 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12700         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12701         CHECK_ACCESS(o_ptr);
12702         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12703         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12704         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12705         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12706         uint32_t ret_ref = (uintptr_t)ret_copy;
12707         return ret_ref;
12708 }
12709
12710 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12711         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12712         *ret_copy = COption_ClosureReasonZ_none();
12713         uint32_t ret_ref = (uintptr_t)ret_copy;
12714         return ret_ref;
12715 }
12716
12717 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12718         if ((_res & 1) != 0) return;
12719         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12720         CHECK_ACCESS(_res_ptr);
12721         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12722         FREE((void*)_res);
12723         COption_ClosureReasonZ_free(_res_conv);
12724 }
12725
12726 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12727         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12728         *ret_copy = COption_ClosureReasonZ_clone(arg);
12729 uint32_t ret_ref = (uintptr_t)ret_copy;
12730         return ret_ref;
12731 }
12732 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12733         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12734         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12735         return ret_conv;
12736 }
12737
12738 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12739         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12740         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12741         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12742         uint32_t ret_ref = (uintptr_t)ret_copy;
12743         return ret_ref;
12744 }
12745
12746 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12747         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12748         CHECK_ACCESS(o_ptr);
12749         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12750         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12751         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12752         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12753         return (uint32_t)ret_conv;
12754 }
12755
12756 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12757         LDKDecodeError e_conv;
12758         e_conv.inner = (void*)(e & (~1));
12759         e_conv.is_owned = (e & 1) || (e == 0);
12760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12761         e_conv = DecodeError_clone(&e_conv);
12762         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12763         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12764         return (uint32_t)ret_conv;
12765 }
12766
12767 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12768         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12769         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12770         return ret_conv;
12771 }
12772
12773 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12774         if ((_res & 1) != 0) return;
12775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12776         CHECK_ACCESS(_res_ptr);
12777         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12778         FREE((void*)_res);
12779         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12780 }
12781
12782 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12783         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12784         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12785         return (uint32_t)ret_conv;
12786 }
12787 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12788         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12789         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12790         return ret_conv;
12791 }
12792
12793 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12794         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12795         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12796         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12797         return (uint32_t)ret_conv;
12798 }
12799
12800 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12801         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12802         CHECK_ACCESS(o_ptr);
12803         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12804         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12805         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12806         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12807         uint32_t ret_ref = (uintptr_t)ret_copy;
12808         return ret_ref;
12809 }
12810
12811 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12812         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12813         *ret_copy = COption_NetworkUpdateZ_none();
12814         uint32_t ret_ref = (uintptr_t)ret_copy;
12815         return ret_ref;
12816 }
12817
12818 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12819         if ((_res & 1) != 0) return;
12820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12821         CHECK_ACCESS(_res_ptr);
12822         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12823         FREE((void*)_res);
12824         COption_NetworkUpdateZ_free(_res_conv);
12825 }
12826
12827 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12828         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12829         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12830 uint32_t ret_ref = (uintptr_t)ret_copy;
12831         return ret_ref;
12832 }
12833 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12834         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12835         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12836         return ret_conv;
12837 }
12838
12839 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12840         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12841         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12842         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12843         uint32_t ret_ref = (uintptr_t)ret_copy;
12844         return ret_ref;
12845 }
12846
12847 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12848         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12849         _res_constr.datalen = _res->arr_len;
12850         if (_res_constr.datalen > 0)
12851                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12852         else
12853                 _res_constr.data = NULL;
12854         uint32_t* _res_vals = _res->elems;
12855         for (size_t b = 0; b < _res_constr.datalen; b++) {
12856                 uint32_t _res_conv_27 = _res_vals[b];
12857                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12858                 CHECK_ACCESS(_res_conv_27_ptr);
12859                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12860                 FREE((void*)_res_conv_27);
12861                 _res_constr.data[b] = _res_conv_27_conv;
12862         }
12863         FREE(_res);
12864         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12865 }
12866
12867 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12868         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12869         CHECK_ACCESS(o_ptr);
12870         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12871         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12872         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12873         *ret_copy = COption_EventZ_some(o_conv);
12874         uint32_t ret_ref = (uintptr_t)ret_copy;
12875         return ret_ref;
12876 }
12877
12878 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12879         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12880         *ret_copy = COption_EventZ_none();
12881         uint32_t ret_ref = (uintptr_t)ret_copy;
12882         return ret_ref;
12883 }
12884
12885 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12886         if ((_res & 1) != 0) return;
12887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12888         CHECK_ACCESS(_res_ptr);
12889         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12890         FREE((void*)_res);
12891         COption_EventZ_free(_res_conv);
12892 }
12893
12894 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12895         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12896         *ret_copy = COption_EventZ_clone(arg);
12897 uint32_t ret_ref = (uintptr_t)ret_copy;
12898         return ret_ref;
12899 }
12900 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12901         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12902         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
12903         return ret_conv;
12904 }
12905
12906 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12907         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12908         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12909         *ret_copy = COption_EventZ_clone(orig_conv);
12910         uint32_t ret_ref = (uintptr_t)ret_copy;
12911         return ret_ref;
12912 }
12913
12914 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12915         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12916         CHECK_ACCESS(o_ptr);
12917         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12918         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12919         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12920         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12921         return (uint32_t)ret_conv;
12922 }
12923
12924 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12925         LDKDecodeError e_conv;
12926         e_conv.inner = (void*)(e & (~1));
12927         e_conv.is_owned = (e & 1) || (e == 0);
12928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12929         e_conv = DecodeError_clone(&e_conv);
12930         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12931         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12932         return (uint32_t)ret_conv;
12933 }
12934
12935 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12936         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12937         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12938         return ret_conv;
12939 }
12940
12941 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12942         if ((_res & 1) != 0) return;
12943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12944         CHECK_ACCESS(_res_ptr);
12945         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12946         FREE((void*)_res);
12947         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12948 }
12949
12950 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12951         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12952         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12953         return (uint32_t)ret_conv;
12954 }
12955 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12956         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12957         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12958         return ret_conv;
12959 }
12960
12961 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12962         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12963         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12964         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12965         return (uint32_t)ret_conv;
12966 }
12967
12968 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12969         LDKCVec_MessageSendEventZ _res_constr;
12970         _res_constr.datalen = _res->arr_len;
12971         if (_res_constr.datalen > 0)
12972                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12973         else
12974                 _res_constr.data = NULL;
12975         uint32_t* _res_vals = _res->elems;
12976         for (size_t s = 0; s < _res_constr.datalen; s++) {
12977                 uint32_t _res_conv_18 = _res_vals[s];
12978                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12979                 CHECK_ACCESS(_res_conv_18_ptr);
12980                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12981                 FREE((void*)_res_conv_18);
12982                 _res_constr.data[s] = _res_conv_18_conv;
12983         }
12984         FREE(_res);
12985         CVec_MessageSendEventZ_free(_res_constr);
12986 }
12987
12988 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12989         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12990         CHECK_ACCESS(o_ptr);
12991         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12992         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12993         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12994         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12995         return (uint32_t)ret_conv;
12996 }
12997
12998 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12999         LDKAccessError e_conv = LDKAccessError_from_js(e);
13000         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13001         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13002         return (uint32_t)ret_conv;
13003 }
13004
13005 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
13006         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13007         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13008         return ret_conv;
13009 }
13010
13011 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
13012         if ((_res & 1) != 0) return;
13013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13014         CHECK_ACCESS(_res_ptr);
13015         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13016         FREE((void*)_res);
13017         CResult_TxOutAccessErrorZ_free(_res_conv);
13018 }
13019
13020 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13021         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13022         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13023         return (uint32_t)ret_conv;
13024 }
13025 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
13026         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13027         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13028         return ret_conv;
13029 }
13030
13031 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
13032         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13033         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13034         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13035         return (uint32_t)ret_conv;
13036 }
13037
13038 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13039         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13040         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13041         return ((uint32_t)ret_conv);
13042 }
13043 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
13044         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13045         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13046         return ret_conv;
13047 }
13048
13049 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
13050         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13051         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13052         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13053         return ((uint32_t)ret_conv);
13054 }
13055
13056 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13057         LDKTransaction b_ref;
13058         b_ref.datalen = b->arr_len;
13059         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13060         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13061         b_ref.data_is_owned = true;
13062         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13063         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13064         return ((uint32_t)ret_conv);
13065 }
13066
13067 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
13068         if ((_res & 1) != 0) return;
13069         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13070         CHECK_ACCESS(_res_ptr);
13071         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13072         FREE((void*)_res);
13073         C2Tuple_usizeTransactionZ_free(_res_conv);
13074 }
13075
13076 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
13077         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13078         _res_constr.datalen = _res->arr_len;
13079         if (_res_constr.datalen > 0)
13080                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13081         else
13082                 _res_constr.data = NULL;
13083         uint32_t* _res_vals = _res->elems;
13084         for (size_t c = 0; c < _res_constr.datalen; c++) {
13085                 uint32_t _res_conv_28 = _res_vals[c];
13086                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
13087                 CHECK_ACCESS(_res_conv_28_ptr);
13088                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13089                 FREE((void*)_res_conv_28);
13090                 _res_constr.data[c] = _res_conv_28_conv;
13091         }
13092         FREE(_res);
13093         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13094 }
13095
13096 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13097         LDKCVec_TxidZ _res_constr;
13098         _res_constr.datalen = _res->arr_len;
13099         if (_res_constr.datalen > 0)
13100                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13101         else
13102                 _res_constr.data = NULL;
13103         int8_tArray* _res_vals = (void*) _res->elems;
13104         for (size_t m = 0; m < _res_constr.datalen; m++) {
13105                 int8_tArray _res_conv_12 = _res_vals[m];
13106                 LDKThirtyTwoBytes _res_conv_12_ref;
13107                 CHECK(_res_conv_12->arr_len == 32);
13108                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13109                 _res_constr.data[m] = _res_conv_12_ref;
13110         }
13111         FREE(_res);
13112         CVec_TxidZ_free(_res_constr);
13113 }
13114
13115 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13116         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13117         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13118         return (uint32_t)ret_conv;
13119 }
13120
13121 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13122         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13123         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13124         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13125         return (uint32_t)ret_conv;
13126 }
13127
13128 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13129         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13130         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13131         return ret_conv;
13132 }
13133
13134 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13135         if ((_res & 1) != 0) return;
13136         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13137         CHECK_ACCESS(_res_ptr);
13138         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13139         FREE((void*)_res);
13140         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13141 }
13142
13143 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13144         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13145         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13146         return (uint32_t)ret_conv;
13147 }
13148 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13149         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13150         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13151         return ret_conv;
13152 }
13153
13154 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13155         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13156         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13157         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13158         return (uint32_t)ret_conv;
13159 }
13160
13161 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13162         LDKCVec_MonitorEventZ _res_constr;
13163         _res_constr.datalen = _res->arr_len;
13164         if (_res_constr.datalen > 0)
13165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13166         else
13167                 _res_constr.data = NULL;
13168         uint32_t* _res_vals = _res->elems;
13169         for (size_t o = 0; o < _res_constr.datalen; o++) {
13170                 uint32_t _res_conv_14 = _res_vals[o];
13171                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13172                 CHECK_ACCESS(_res_conv_14_ptr);
13173                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13174                 FREE((void*)_res_conv_14);
13175                 _res_constr.data[o] = _res_conv_14_conv;
13176         }
13177         FREE(_res);
13178         CVec_MonitorEventZ_free(_res_constr);
13179 }
13180
13181 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
13182         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13183         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
13184         return ((uint32_t)ret_conv);
13185 }
13186 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(uint32_t arg) {
13187         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
13188         uint32_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
13189         return ret_conv;
13190 }
13191
13192 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone(uint32_t orig) {
13193         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
13194         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13195         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
13196         return ((uint32_t)ret_conv);
13197 }
13198
13199 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_new"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_new(uint32_t a, uint32_tArray b) {
13200         LDKOutPoint a_conv;
13201         a_conv.inner = (void*)(a & (~1));
13202         a_conv.is_owned = (a & 1) || (a == 0);
13203         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13204         a_conv = OutPoint_clone(&a_conv);
13205         LDKCVec_MonitorEventZ b_constr;
13206         b_constr.datalen = b->arr_len;
13207         if (b_constr.datalen > 0)
13208                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13209         else
13210                 b_constr.data = NULL;
13211         uint32_t* b_vals = b->elems;
13212         for (size_t o = 0; o < b_constr.datalen; o++) {
13213                 uint32_t b_conv_14 = b_vals[o];
13214                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13215                 CHECK_ACCESS(b_conv_14_ptr);
13216                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13217                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13218                 b_constr.data[o] = b_conv_14_conv;
13219         }
13220         FREE(b);
13221         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13222         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
13223         return ((uint32_t)ret_conv);
13224 }
13225
13226 void  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_free"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_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         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
13231         FREE((void*)_res);
13232         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
13233 }
13234
13235 void  __attribute__((export_name("TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free"))) TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(uint32_tArray _res) {
13236         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
13237         _res_constr.datalen = _res->arr_len;
13238         if (_res_constr.datalen > 0)
13239                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
13240         else
13241                 _res_constr.data = NULL;
13242         uint32_t* _res_vals = _res->elems;
13243         for (size_t m = 0; m < _res_constr.datalen; m++) {
13244                 uint32_t _res_conv_38 = _res_vals[m];
13245                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
13246                 CHECK_ACCESS(_res_conv_38_ptr);
13247                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
13248                 FREE((void*)_res_conv_38);
13249                 _res_constr.data[m] = _res_conv_38_conv;
13250         }
13251         FREE(_res);
13252         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
13253 }
13254
13255 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13256         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13257         CHECK_ACCESS(o_ptr);
13258         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13259         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13260         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13261         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13262         uint32_t ret_ref = (uintptr_t)ret_copy;
13263         return ret_ref;
13264 }
13265
13266 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13267         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13268         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13269         uint32_t ret_ref = (uintptr_t)ret_copy;
13270         return ret_ref;
13271 }
13272
13273 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13274         if ((_res & 1) != 0) return;
13275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13276         CHECK_ACCESS(_res_ptr);
13277         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13278         FREE((void*)_res);
13279         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13280 }
13281
13282 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13283         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13284         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13285 uint32_t ret_ref = (uintptr_t)ret_copy;
13286         return ret_ref;
13287 }
13288 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13289         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13290         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13291         return ret_conv;
13292 }
13293
13294 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13295         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13296         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13297         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13298         uint32_t ret_ref = (uintptr_t)ret_copy;
13299         return ret_ref;
13300 }
13301
13302 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13303         LDKFixedPenaltyScorer o_conv;
13304         o_conv.inner = (void*)(o & (~1));
13305         o_conv.is_owned = (o & 1) || (o == 0);
13306         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13307         o_conv = FixedPenaltyScorer_clone(&o_conv);
13308         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13309         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13310         return (uint32_t)ret_conv;
13311 }
13312
13313 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13314         LDKDecodeError e_conv;
13315         e_conv.inner = (void*)(e & (~1));
13316         e_conv.is_owned = (e & 1) || (e == 0);
13317         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13318         e_conv = DecodeError_clone(&e_conv);
13319         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13320         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13321         return (uint32_t)ret_conv;
13322 }
13323
13324 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13325         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13326         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13327         return ret_conv;
13328 }
13329
13330 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13331         if ((_res & 1) != 0) return;
13332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13333         CHECK_ACCESS(_res_ptr);
13334         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13335         FREE((void*)_res);
13336         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13337 }
13338
13339 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13340         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13341         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13342         return (uint32_t)ret_conv;
13343 }
13344 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13345         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13346         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13347         return ret_conv;
13348 }
13349
13350 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13351         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13352         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13353         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13354         return (uint32_t)ret_conv;
13355 }
13356
13357 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13358         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13359         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13360         return ((uint32_t)ret_conv);
13361 }
13362 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint32_t arg) {
13363         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
13364         uint32_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13365         return ret_conv;
13366 }
13367
13368 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
13369         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
13370         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13371         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13372         return ((uint32_t)ret_conv);
13373 }
13374
13375 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13376         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13377         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13378         return ((uint32_t)ret_conv);
13379 }
13380
13381 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
13382         if ((_res & 1) != 0) return;
13383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13384         CHECK_ACCESS(_res_ptr);
13385         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13386         FREE((void*)_res);
13387         C2Tuple_u64u64Z_free(_res_conv);
13388 }
13389
13390 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint32_t o) {
13391         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13392         CHECK_ACCESS(o_ptr);
13393         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13394         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
13395         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13396         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13397         uint32_t ret_ref = (uintptr_t)ret_copy;
13398         return ret_ref;
13399 }
13400
13401 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13402         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13403         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13404         uint32_t ret_ref = (uintptr_t)ret_copy;
13405         return ret_ref;
13406 }
13407
13408 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint32_t _res) {
13409         if ((_res & 1) != 0) return;
13410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13411         CHECK_ACCESS(_res_ptr);
13412         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13413         FREE((void*)_res);
13414         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13415 }
13416
13417 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13418         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13419         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13420 uint32_t ret_ref = (uintptr_t)ret_copy;
13421         return ret_ref;
13422 }
13423 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint32_t arg) {
13424         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
13425         uint32_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13426         return ret_conv;
13427 }
13428
13429 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint32_t orig) {
13430         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
13431         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13432         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13433         uint32_t ret_ref = (uintptr_t)ret_copy;
13434         return ret_ref;
13435 }
13436
13437 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint32_tArray _res) {
13438         LDKCVec_NodeIdZ _res_constr;
13439         _res_constr.datalen = _res->arr_len;
13440         if (_res_constr.datalen > 0)
13441                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13442         else
13443                 _res_constr.data = NULL;
13444         uint32_t* _res_vals = _res->elems;
13445         for (size_t i = 0; i < _res_constr.datalen; i++) {
13446                 uint32_t _res_conv_8 = _res_vals[i];
13447                 LDKNodeId _res_conv_8_conv;
13448                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
13449                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
13450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13451                 _res_constr.data[i] = _res_conv_8_conv;
13452         }
13453         FREE(_res);
13454         CVec_NodeIdZ_free(_res_constr);
13455 }
13456
13457 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13458         LDKProbabilisticScorer o_conv;
13459         o_conv.inner = (void*)(o & (~1));
13460         o_conv.is_owned = (o & 1) || (o == 0);
13461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13462         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13463         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13464         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13465         return (uint32_t)ret_conv;
13466 }
13467
13468 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13469         LDKDecodeError e_conv;
13470         e_conv.inner = (void*)(e & (~1));
13471         e_conv.is_owned = (e & 1) || (e == 0);
13472         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13473         e_conv = DecodeError_clone(&e_conv);
13474         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13475         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13476         return (uint32_t)ret_conv;
13477 }
13478
13479 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13480         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13481         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13482         return ret_conv;
13483 }
13484
13485 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13486         if ((_res & 1) != 0) return;
13487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13488         CHECK_ACCESS(_res_ptr);
13489         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13490         FREE((void*)_res);
13491         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13492 }
13493
13494 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13495         LDKInitFeatures o_conv;
13496         o_conv.inner = (void*)(o & (~1));
13497         o_conv.is_owned = (o & 1) || (o == 0);
13498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13499         o_conv = InitFeatures_clone(&o_conv);
13500         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13501         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13502         return (uint32_t)ret_conv;
13503 }
13504
13505 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13506         LDKDecodeError e_conv;
13507         e_conv.inner = (void*)(e & (~1));
13508         e_conv.is_owned = (e & 1) || (e == 0);
13509         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13510         e_conv = DecodeError_clone(&e_conv);
13511         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13512         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13513         return (uint32_t)ret_conv;
13514 }
13515
13516 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13517         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13518         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13519         return ret_conv;
13520 }
13521
13522 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
13523         if ((_res & 1) != 0) return;
13524         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13525         CHECK_ACCESS(_res_ptr);
13526         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13527         FREE((void*)_res);
13528         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13529 }
13530
13531 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13532         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13533         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13534         return (uint32_t)ret_conv;
13535 }
13536 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13537         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13538         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13539         return ret_conv;
13540 }
13541
13542 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13543         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13544         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13545         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13546         return (uint32_t)ret_conv;
13547 }
13548
13549 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13550         LDKChannelFeatures o_conv;
13551         o_conv.inner = (void*)(o & (~1));
13552         o_conv.is_owned = (o & 1) || (o == 0);
13553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13554         o_conv = ChannelFeatures_clone(&o_conv);
13555         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13556         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13557         return (uint32_t)ret_conv;
13558 }
13559
13560 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13561         LDKDecodeError e_conv;
13562         e_conv.inner = (void*)(e & (~1));
13563         e_conv.is_owned = (e & 1) || (e == 0);
13564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13565         e_conv = DecodeError_clone(&e_conv);
13566         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13567         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13568         return (uint32_t)ret_conv;
13569 }
13570
13571 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13572         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13573         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13574         return ret_conv;
13575 }
13576
13577 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13578         if ((_res & 1) != 0) return;
13579         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13580         CHECK_ACCESS(_res_ptr);
13581         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13582         FREE((void*)_res);
13583         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13584 }
13585
13586 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13587         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13588         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
13589         return (uint32_t)ret_conv;
13590 }
13591 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13592         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
13593         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13594         return ret_conv;
13595 }
13596
13597 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
13598         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
13599         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13600         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
13601         return (uint32_t)ret_conv;
13602 }
13603
13604 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
13605         LDKNodeFeatures o_conv;
13606         o_conv.inner = (void*)(o & (~1));
13607         o_conv.is_owned = (o & 1) || (o == 0);
13608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13609         o_conv = NodeFeatures_clone(&o_conv);
13610         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13611         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13612         return (uint32_t)ret_conv;
13613 }
13614
13615 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
13616         LDKDecodeError e_conv;
13617         e_conv.inner = (void*)(e & (~1));
13618         e_conv.is_owned = (e & 1) || (e == 0);
13619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13620         e_conv = DecodeError_clone(&e_conv);
13621         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13622         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13623         return (uint32_t)ret_conv;
13624 }
13625
13626 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13627         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13628         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13629         return ret_conv;
13630 }
13631
13632 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
13633         if ((_res & 1) != 0) return;
13634         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13635         CHECK_ACCESS(_res_ptr);
13636         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13637         FREE((void*)_res);
13638         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13639 }
13640
13641 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13642         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13643         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
13644         return (uint32_t)ret_conv;
13645 }
13646 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13647         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
13648         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13649         return ret_conv;
13650 }
13651
13652 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13653         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
13654         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13655         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
13656         return (uint32_t)ret_conv;
13657 }
13658
13659 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
13660         LDKInvoiceFeatures o_conv;
13661         o_conv.inner = (void*)(o & (~1));
13662         o_conv.is_owned = (o & 1) || (o == 0);
13663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13664         o_conv = InvoiceFeatures_clone(&o_conv);
13665         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13666         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13667         return (uint32_t)ret_conv;
13668 }
13669
13670 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
13671         LDKDecodeError e_conv;
13672         e_conv.inner = (void*)(e & (~1));
13673         e_conv.is_owned = (e & 1) || (e == 0);
13674         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13675         e_conv = DecodeError_clone(&e_conv);
13676         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13677         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13678         return (uint32_t)ret_conv;
13679 }
13680
13681 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13682         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13683         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13684         return ret_conv;
13685 }
13686
13687 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
13688         if ((_res & 1) != 0) return;
13689         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13690         CHECK_ACCESS(_res_ptr);
13691         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13692         FREE((void*)_res);
13693         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13694 }
13695
13696 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13697         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13698         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
13699         return (uint32_t)ret_conv;
13700 }
13701 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13702         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
13703         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13704         return ret_conv;
13705 }
13706
13707 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
13708         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
13709         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13710         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
13711         return (uint32_t)ret_conv;
13712 }
13713
13714 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
13715         LDKChannelTypeFeatures o_conv;
13716         o_conv.inner = (void*)(o & (~1));
13717         o_conv.is_owned = (o & 1) || (o == 0);
13718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13719         o_conv = ChannelTypeFeatures_clone(&o_conv);
13720         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13721         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13722         return (uint32_t)ret_conv;
13723 }
13724
13725 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13726         LDKDecodeError e_conv;
13727         e_conv.inner = (void*)(e & (~1));
13728         e_conv.is_owned = (e & 1) || (e == 0);
13729         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13730         e_conv = DecodeError_clone(&e_conv);
13731         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13732         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13733         return (uint32_t)ret_conv;
13734 }
13735
13736 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13737         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13738         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13739         return ret_conv;
13740 }
13741
13742 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13743         if ((_res & 1) != 0) return;
13744         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13745         CHECK_ACCESS(_res_ptr);
13746         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13747         FREE((void*)_res);
13748         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13749 }
13750
13751 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13752         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13753         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
13754         return (uint32_t)ret_conv;
13755 }
13756 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13757         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
13758         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13759         return ret_conv;
13760 }
13761
13762 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13763         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
13764         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13765         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
13766         return (uint32_t)ret_conv;
13767 }
13768
13769 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
13770         LDKNodeId o_conv;
13771         o_conv.inner = (void*)(o & (~1));
13772         o_conv.is_owned = (o & 1) || (o == 0);
13773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13774         o_conv = NodeId_clone(&o_conv);
13775         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13776         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13777         return (uint32_t)ret_conv;
13778 }
13779
13780 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
13781         LDKDecodeError e_conv;
13782         e_conv.inner = (void*)(e & (~1));
13783         e_conv.is_owned = (e & 1) || (e == 0);
13784         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13785         e_conv = DecodeError_clone(&e_conv);
13786         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13787         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13788         return (uint32_t)ret_conv;
13789 }
13790
13791 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
13792         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
13793         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
13794         return ret_conv;
13795 }
13796
13797 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
13798         if ((_res & 1) != 0) return;
13799         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13800         CHECK_ACCESS(_res_ptr);
13801         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
13802         FREE((void*)_res);
13803         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13804 }
13805
13806 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
13807         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13808         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
13809         return (uint32_t)ret_conv;
13810 }
13811 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
13812         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
13813         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
13814         return ret_conv;
13815 }
13816
13817 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
13818         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13819         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13820         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13821         return (uint32_t)ret_conv;
13822 }
13823
13824 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
13825         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13826         CHECK_ACCESS(o_ptr);
13827         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
13828         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
13829         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13830         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
13831         return (uint32_t)ret_conv;
13832 }
13833
13834 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
13835         LDKDecodeError e_conv;
13836         e_conv.inner = (void*)(e & (~1));
13837         e_conv.is_owned = (e & 1) || (e == 0);
13838         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13839         e_conv = DecodeError_clone(&e_conv);
13840         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13841         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
13842         return (uint32_t)ret_conv;
13843 }
13844
13845 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
13846         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
13847         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
13848         return ret_conv;
13849 }
13850
13851 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
13852         if ((_res & 1) != 0) return;
13853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13854         CHECK_ACCESS(_res_ptr);
13855         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
13856         FREE((void*)_res);
13857         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
13858 }
13859
13860 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
13861         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13862         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
13863         return (uint32_t)ret_conv;
13864 }
13865 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
13866         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
13867         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
13868         return ret_conv;
13869 }
13870
13871 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
13872         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
13873         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13874         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
13875         return (uint32_t)ret_conv;
13876 }
13877
13878 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
13879         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13880         CHECK_ACCESS(o_ptr);
13881         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
13882         if (o_conv.free == LDKAccess_JCalls_free) {
13883                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13884                 LDKAccess_JCalls_cloned(&o_conv);
13885         }
13886         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13887         *ret_copy = COption_AccessZ_some(o_conv);
13888         uint32_t ret_ref = (uintptr_t)ret_copy;
13889         return ret_ref;
13890 }
13891
13892 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
13893         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13894         *ret_copy = COption_AccessZ_none();
13895         uint32_t ret_ref = (uintptr_t)ret_copy;
13896         return ret_ref;
13897 }
13898
13899 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
13900         if ((_res & 1) != 0) return;
13901         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13902         CHECK_ACCESS(_res_ptr);
13903         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
13904         FREE((void*)_res);
13905         COption_AccessZ_free(_res_conv);
13906 }
13907
13908 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
13909         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13910         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13911         return (uint32_t)ret_conv;
13912 }
13913
13914 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
13915         LDKLightningError e_conv;
13916         e_conv.inner = (void*)(e & (~1));
13917         e_conv.is_owned = (e & 1) || (e == 0);
13918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13919         e_conv = LightningError_clone(&e_conv);
13920         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13921         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13922         return (uint32_t)ret_conv;
13923 }
13924
13925 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
13926         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
13927         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
13928         return ret_conv;
13929 }
13930
13931 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
13932         if ((_res & 1) != 0) return;
13933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13934         CHECK_ACCESS(_res_ptr);
13935         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13936         FREE((void*)_res);
13937         CResult_boolLightningErrorZ_free(_res_conv);
13938 }
13939
13940 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
13941         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13942         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
13943         return (uint32_t)ret_conv;
13944 }
13945 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
13946         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
13947         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
13948         return ret_conv;
13949 }
13950
13951 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
13952         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13953         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13954         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13955         return (uint32_t)ret_conv;
13956 }
13957
13958 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
13959         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13960         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
13961         return ((uint32_t)ret_conv);
13962 }
13963 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
13964         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
13965         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
13966         return ret_conv;
13967 }
13968
13969 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
13970         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13971         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13972         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13973         return ((uint32_t)ret_conv);
13974 }
13975
13976 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
13977         LDKChannelAnnouncement a_conv;
13978         a_conv.inner = (void*)(a & (~1));
13979         a_conv.is_owned = (a & 1) || (a == 0);
13980         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13981         a_conv = ChannelAnnouncement_clone(&a_conv);
13982         LDKChannelUpdate b_conv;
13983         b_conv.inner = (void*)(b & (~1));
13984         b_conv.is_owned = (b & 1) || (b == 0);
13985         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13986         b_conv = ChannelUpdate_clone(&b_conv);
13987         LDKChannelUpdate c_conv;
13988         c_conv.inner = (void*)(c & (~1));
13989         c_conv.is_owned = (c & 1) || (c == 0);
13990         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
13991         c_conv = ChannelUpdate_clone(&c_conv);
13992         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13993         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13994         return ((uint32_t)ret_conv);
13995 }
13996
13997 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
13998         if ((_res & 1) != 0) return;
13999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14000         CHECK_ACCESS(_res_ptr);
14001         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14002         FREE((void*)_res);
14003         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14004 }
14005
14006 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
14007         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
14008         _res_constr.datalen = _res->arr_len;
14009         if (_res_constr.datalen > 0)
14010                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
14011         else
14012                 _res_constr.data = NULL;
14013         uint32_t* _res_vals = _res->elems;
14014         for (size_t h = 0; h < _res_constr.datalen; h++) {
14015                 uint32_t _res_conv_59 = _res_vals[h];
14016                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
14017                 CHECK_ACCESS(_res_conv_59_ptr);
14018                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
14019                 FREE((void*)_res_conv_59);
14020                 _res_constr.data[h] = _res_conv_59_conv;
14021         }
14022         FREE(_res);
14023         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
14024 }
14025
14026 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
14027         LDKCVec_NodeAnnouncementZ _res_constr;
14028         _res_constr.datalen = _res->arr_len;
14029         if (_res_constr.datalen > 0)
14030                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
14031         else
14032                 _res_constr.data = NULL;
14033         uint32_t* _res_vals = _res->elems;
14034         for (size_t s = 0; s < _res_constr.datalen; s++) {
14035                 uint32_t _res_conv_18 = _res_vals[s];
14036                 LDKNodeAnnouncement _res_conv_18_conv;
14037                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
14038                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
14039                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
14040                 _res_constr.data[s] = _res_conv_18_conv;
14041         }
14042         FREE(_res);
14043         CVec_NodeAnnouncementZ_free(_res_constr);
14044 }
14045
14046 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14047         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14048         *ret_conv = CResult_NoneLightningErrorZ_ok();
14049         return (uint32_t)ret_conv;
14050 }
14051
14052 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
14053         LDKLightningError e_conv;
14054         e_conv.inner = (void*)(e & (~1));
14055         e_conv.is_owned = (e & 1) || (e == 0);
14056         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14057         e_conv = LightningError_clone(&e_conv);
14058         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14059         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14060         return (uint32_t)ret_conv;
14061 }
14062
14063 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
14064         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
14065         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14066         return ret_conv;
14067 }
14068
14069 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
14070         if ((_res & 1) != 0) return;
14071         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14072         CHECK_ACCESS(_res_ptr);
14073         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14074         FREE((void*)_res);
14075         CResult_NoneLightningErrorZ_free(_res_conv);
14076 }
14077
14078 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14079         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14080         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14081         return (uint32_t)ret_conv;
14082 }
14083 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
14084         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
14085         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14086         return ret_conv;
14087 }
14088
14089 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
14090         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
14091         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14092         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14093         return (uint32_t)ret_conv;
14094 }
14095
14096 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
14097         LDKChannelUpdateInfo o_conv;
14098         o_conv.inner = (void*)(o & (~1));
14099         o_conv.is_owned = (o & 1) || (o == 0);
14100         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14101         o_conv = ChannelUpdateInfo_clone(&o_conv);
14102         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14103         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14104         return (uint32_t)ret_conv;
14105 }
14106
14107 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
14108         LDKDecodeError e_conv;
14109         e_conv.inner = (void*)(e & (~1));
14110         e_conv.is_owned = (e & 1) || (e == 0);
14111         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14112         e_conv = DecodeError_clone(&e_conv);
14113         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14114         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14115         return (uint32_t)ret_conv;
14116 }
14117
14118 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
14119         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
14120         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14121         return ret_conv;
14122 }
14123
14124 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
14125         if ((_res & 1) != 0) return;
14126         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14127         CHECK_ACCESS(_res_ptr);
14128         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14129         FREE((void*)_res);
14130         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14131 }
14132
14133 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14134         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14135         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14136         return (uint32_t)ret_conv;
14137 }
14138 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14139         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
14140         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14141         return ret_conv;
14142 }
14143
14144 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
14145         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
14146         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14147         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14148         return (uint32_t)ret_conv;
14149 }
14150
14151 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14152         LDKChannelInfo o_conv;
14153         o_conv.inner = (void*)(o & (~1));
14154         o_conv.is_owned = (o & 1) || (o == 0);
14155         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14156         o_conv = ChannelInfo_clone(&o_conv);
14157         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14158         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14159         return (uint32_t)ret_conv;
14160 }
14161
14162 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14163         LDKDecodeError e_conv;
14164         e_conv.inner = (void*)(e & (~1));
14165         e_conv.is_owned = (e & 1) || (e == 0);
14166         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14167         e_conv = DecodeError_clone(&e_conv);
14168         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14169         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14170         return (uint32_t)ret_conv;
14171 }
14172
14173 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14174         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14175         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14176         return ret_conv;
14177 }
14178
14179 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14180         if ((_res & 1) != 0) return;
14181         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14182         CHECK_ACCESS(_res_ptr);
14183         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14184         FREE((void*)_res);
14185         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14186 }
14187
14188 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14189         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14190         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14191         return (uint32_t)ret_conv;
14192 }
14193 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14194         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14195         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14196         return ret_conv;
14197 }
14198
14199 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14200         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14201         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14202         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14203         return (uint32_t)ret_conv;
14204 }
14205
14206 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14207         LDKRoutingFees o_conv;
14208         o_conv.inner = (void*)(o & (~1));
14209         o_conv.is_owned = (o & 1) || (o == 0);
14210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14211         o_conv = RoutingFees_clone(&o_conv);
14212         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14213         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14214         return (uint32_t)ret_conv;
14215 }
14216
14217 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14218         LDKDecodeError e_conv;
14219         e_conv.inner = (void*)(e & (~1));
14220         e_conv.is_owned = (e & 1) || (e == 0);
14221         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14222         e_conv = DecodeError_clone(&e_conv);
14223         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14224         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14225         return (uint32_t)ret_conv;
14226 }
14227
14228 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14229         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14230         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14231         return ret_conv;
14232 }
14233
14234 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14235         if ((_res & 1) != 0) return;
14236         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14237         CHECK_ACCESS(_res_ptr);
14238         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14239         FREE((void*)_res);
14240         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14241 }
14242
14243 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14244         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14245         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14246         return (uint32_t)ret_conv;
14247 }
14248 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14249         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14250         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14251         return ret_conv;
14252 }
14253
14254 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14255         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14256         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14257         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14258         return (uint32_t)ret_conv;
14259 }
14260
14261 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14262         LDKCVec_NetAddressZ _res_constr;
14263         _res_constr.datalen = _res->arr_len;
14264         if (_res_constr.datalen > 0)
14265                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14266         else
14267                 _res_constr.data = NULL;
14268         uint32_t* _res_vals = _res->elems;
14269         for (size_t m = 0; m < _res_constr.datalen; m++) {
14270                 uint32_t _res_conv_12 = _res_vals[m];
14271                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14272                 CHECK_ACCESS(_res_conv_12_ptr);
14273                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14274                 FREE((void*)_res_conv_12);
14275                 _res_constr.data[m] = _res_conv_12_conv;
14276         }
14277         FREE(_res);
14278         CVec_NetAddressZ_free(_res_constr);
14279 }
14280
14281 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14282         LDKNodeAnnouncementInfo o_conv;
14283         o_conv.inner = (void*)(o & (~1));
14284         o_conv.is_owned = (o & 1) || (o == 0);
14285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14286         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14287         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14288         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14289         return (uint32_t)ret_conv;
14290 }
14291
14292 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14293         LDKDecodeError e_conv;
14294         e_conv.inner = (void*)(e & (~1));
14295         e_conv.is_owned = (e & 1) || (e == 0);
14296         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14297         e_conv = DecodeError_clone(&e_conv);
14298         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14299         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14300         return (uint32_t)ret_conv;
14301 }
14302
14303 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14304         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14305         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14306         return ret_conv;
14307 }
14308
14309 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14310         if ((_res & 1) != 0) return;
14311         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14312         CHECK_ACCESS(_res_ptr);
14313         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14314         FREE((void*)_res);
14315         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14316 }
14317
14318 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14319         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14320         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14321         return (uint32_t)ret_conv;
14322 }
14323 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14324         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14325         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14326         return ret_conv;
14327 }
14328
14329 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14330         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14331         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14332         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14333         return (uint32_t)ret_conv;
14334 }
14335
14336 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint32_t o) {
14337         LDKNodeAlias o_conv;
14338         o_conv.inner = (void*)(o & (~1));
14339         o_conv.is_owned = (o & 1) || (o == 0);
14340         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14341         o_conv = NodeAlias_clone(&o_conv);
14342         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14343         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14344         return (uint32_t)ret_conv;
14345 }
14346
14347 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint32_t e) {
14348         LDKDecodeError e_conv;
14349         e_conv.inner = (void*)(e & (~1));
14350         e_conv.is_owned = (e & 1) || (e == 0);
14351         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14352         e_conv = DecodeError_clone(&e_conv);
14353         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14354         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14355         return (uint32_t)ret_conv;
14356 }
14357
14358 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint32_t o) {
14359         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
14360         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14361         return ret_conv;
14362 }
14363
14364 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint32_t _res) {
14365         if ((_res & 1) != 0) return;
14366         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14367         CHECK_ACCESS(_res_ptr);
14368         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14369         FREE((void*)_res);
14370         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14371 }
14372
14373 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14374         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14375         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14376         return (uint32_t)ret_conv;
14377 }
14378 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint32_t arg) {
14379         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
14380         uint32_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14381         return ret_conv;
14382 }
14383
14384 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint32_t orig) {
14385         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
14386         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14387         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14388         return (uint32_t)ret_conv;
14389 }
14390
14391 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
14392         LDKCVec_u64Z _res_constr;
14393         _res_constr.datalen = _res->arr_len;
14394         if (_res_constr.datalen > 0)
14395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14396         else
14397                 _res_constr.data = NULL;
14398         int64_t* _res_vals = _res->elems;
14399         for (size_t i = 0; i < _res_constr.datalen; i++) {
14400                 int64_t _res_conv_8 = _res_vals[i];
14401                 _res_constr.data[i] = _res_conv_8;
14402         }
14403         FREE(_res);
14404         CVec_u64Z_free(_res_constr);
14405 }
14406
14407 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14408         LDKNodeInfo o_conv;
14409         o_conv.inner = (void*)(o & (~1));
14410         o_conv.is_owned = (o & 1) || (o == 0);
14411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14412         o_conv = NodeInfo_clone(&o_conv);
14413         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14414         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14415         return (uint32_t)ret_conv;
14416 }
14417
14418 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14419         LDKDecodeError e_conv;
14420         e_conv.inner = (void*)(e & (~1));
14421         e_conv.is_owned = (e & 1) || (e == 0);
14422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14423         e_conv = DecodeError_clone(&e_conv);
14424         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14425         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14426         return (uint32_t)ret_conv;
14427 }
14428
14429 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14430         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14431         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14432         return ret_conv;
14433 }
14434
14435 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14436         if ((_res & 1) != 0) return;
14437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14438         CHECK_ACCESS(_res_ptr);
14439         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14440         FREE((void*)_res);
14441         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14442 }
14443
14444 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14445         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14446         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14447         return (uint32_t)ret_conv;
14448 }
14449 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14450         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14451         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14452         return ret_conv;
14453 }
14454
14455 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14456         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14457         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14458         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14459         return (uint32_t)ret_conv;
14460 }
14461
14462 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14463         LDKNetworkGraph o_conv;
14464         o_conv.inner = (void*)(o & (~1));
14465         o_conv.is_owned = (o & 1) || (o == 0);
14466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14467         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14468         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14469         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14470         return (uint32_t)ret_conv;
14471 }
14472
14473 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14474         LDKDecodeError e_conv;
14475         e_conv.inner = (void*)(e & (~1));
14476         e_conv.is_owned = (e & 1) || (e == 0);
14477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14478         e_conv = DecodeError_clone(&e_conv);
14479         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14480         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14481         return (uint32_t)ret_conv;
14482 }
14483
14484 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14485         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14486         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14487         return ret_conv;
14488 }
14489
14490 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14491         if ((_res & 1) != 0) return;
14492         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14493         CHECK_ACCESS(_res_ptr);
14494         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14495         FREE((void*)_res);
14496         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14497 }
14498
14499 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14500         LDKCVec_NetAddressZ o_constr;
14501         o_constr.datalen = o->arr_len;
14502         if (o_constr.datalen > 0)
14503                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14504         else
14505                 o_constr.data = NULL;
14506         uint32_t* o_vals = o->elems;
14507         for (size_t m = 0; m < o_constr.datalen; m++) {
14508                 uint32_t o_conv_12 = o_vals[m];
14509                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14510                 CHECK_ACCESS(o_conv_12_ptr);
14511                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14512                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14513                 o_constr.data[m] = o_conv_12_conv;
14514         }
14515         FREE(o);
14516         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14517         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14518         uint32_t ret_ref = (uintptr_t)ret_copy;
14519         return ret_ref;
14520 }
14521
14522 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14523         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14524         *ret_copy = COption_CVec_NetAddressZZ_none();
14525         uint32_t ret_ref = (uintptr_t)ret_copy;
14526         return ret_ref;
14527 }
14528
14529 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14530         if ((_res & 1) != 0) return;
14531         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14532         CHECK_ACCESS(_res_ptr);
14533         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14534         FREE((void*)_res);
14535         COption_CVec_NetAddressZZ_free(_res_conv);
14536 }
14537
14538 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14539         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14540         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14541 uint32_t ret_ref = (uintptr_t)ret_copy;
14542         return ret_ref;
14543 }
14544 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14545         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14546         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14547         return ret_conv;
14548 }
14549
14550 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14551         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14552         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14553         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14554         uint32_t ret_ref = (uintptr_t)ret_copy;
14555         return ret_ref;
14556 }
14557
14558 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14559         LDKDelayedPaymentOutputDescriptor o_conv;
14560         o_conv.inner = (void*)(o & (~1));
14561         o_conv.is_owned = (o & 1) || (o == 0);
14562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14563         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14564         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14565         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14566         return (uint32_t)ret_conv;
14567 }
14568
14569 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14570         LDKDecodeError e_conv;
14571         e_conv.inner = (void*)(e & (~1));
14572         e_conv.is_owned = (e & 1) || (e == 0);
14573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14574         e_conv = DecodeError_clone(&e_conv);
14575         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14576         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14577         return (uint32_t)ret_conv;
14578 }
14579
14580 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14581         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14582         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14583         return ret_conv;
14584 }
14585
14586 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14587         if ((_res & 1) != 0) return;
14588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14589         CHECK_ACCESS(_res_ptr);
14590         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14591         FREE((void*)_res);
14592         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14593 }
14594
14595 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14596         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14597         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14598         return (uint32_t)ret_conv;
14599 }
14600 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14601         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14602         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14603         return ret_conv;
14604 }
14605
14606 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14607         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14608         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14609         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14610         return (uint32_t)ret_conv;
14611 }
14612
14613 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14614         LDKStaticPaymentOutputDescriptor o_conv;
14615         o_conv.inner = (void*)(o & (~1));
14616         o_conv.is_owned = (o & 1) || (o == 0);
14617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14618         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14619         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14620         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14621         return (uint32_t)ret_conv;
14622 }
14623
14624 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14625         LDKDecodeError e_conv;
14626         e_conv.inner = (void*)(e & (~1));
14627         e_conv.is_owned = (e & 1) || (e == 0);
14628         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14629         e_conv = DecodeError_clone(&e_conv);
14630         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14631         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14632         return (uint32_t)ret_conv;
14633 }
14634
14635 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14636         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14637         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14638         return ret_conv;
14639 }
14640
14641 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14642         if ((_res & 1) != 0) return;
14643         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14644         CHECK_ACCESS(_res_ptr);
14645         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14646         FREE((void*)_res);
14647         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14648 }
14649
14650 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14651         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14652         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14653         return (uint32_t)ret_conv;
14654 }
14655 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14656         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14657         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14658         return ret_conv;
14659 }
14660
14661 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14662         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14663         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14664         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14665         return (uint32_t)ret_conv;
14666 }
14667
14668 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14669         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14670         CHECK_ACCESS(o_ptr);
14671         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
14672         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
14673         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14674         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
14675         return (uint32_t)ret_conv;
14676 }
14677
14678 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14679         LDKDecodeError e_conv;
14680         e_conv.inner = (void*)(e & (~1));
14681         e_conv.is_owned = (e & 1) || (e == 0);
14682         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14683         e_conv = DecodeError_clone(&e_conv);
14684         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14685         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
14686         return (uint32_t)ret_conv;
14687 }
14688
14689 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14690         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
14691         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14692         return ret_conv;
14693 }
14694
14695 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14696         if ((_res & 1) != 0) return;
14697         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14698         CHECK_ACCESS(_res_ptr);
14699         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
14700         FREE((void*)_res);
14701         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
14702 }
14703
14704 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14705         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14706         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
14707         return (uint32_t)ret_conv;
14708 }
14709 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14710         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
14711         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14712         return ret_conv;
14713 }
14714
14715 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14716         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
14717         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14718         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
14719         return (uint32_t)ret_conv;
14720 }
14721
14722 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
14723         LDKCVec_PaymentPreimageZ _res_constr;
14724         _res_constr.datalen = _res->arr_len;
14725         if (_res_constr.datalen > 0)
14726                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
14727         else
14728                 _res_constr.data = NULL;
14729         int8_tArray* _res_vals = (void*) _res->elems;
14730         for (size_t m = 0; m < _res_constr.datalen; m++) {
14731                 int8_tArray _res_conv_12 = _res_vals[m];
14732                 LDKThirtyTwoBytes _res_conv_12_ref;
14733                 CHECK(_res_conv_12->arr_len == 32);
14734                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
14735                 _res_constr.data[m] = _res_conv_12_ref;
14736         }
14737         FREE(_res);
14738         CVec_PaymentPreimageZ_free(_res_constr);
14739 }
14740
14741 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
14742         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14743         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
14744         return ((uint32_t)ret_conv);
14745 }
14746 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
14747         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
14748         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
14749         return ret_conv;
14750 }
14751
14752 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
14753         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
14754         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14755         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
14756         return ((uint32_t)ret_conv);
14757 }
14758
14759 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
14760         LDKSignature a_ref;
14761         CHECK(a->arr_len == 64);
14762         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14763         LDKCVec_SignatureZ b_constr;
14764         b_constr.datalen = b->arr_len;
14765         if (b_constr.datalen > 0)
14766                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14767         else
14768                 b_constr.data = NULL;
14769         int8_tArray* b_vals = (void*) b->elems;
14770         for (size_t m = 0; m < b_constr.datalen; m++) {
14771                 int8_tArray b_conv_12 = b_vals[m];
14772                 LDKSignature b_conv_12_ref;
14773                 CHECK(b_conv_12->arr_len == 64);
14774                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
14775                 b_constr.data[m] = b_conv_12_ref;
14776         }
14777         FREE(b);
14778         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14779         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
14780         return ((uint32_t)ret_conv);
14781 }
14782
14783 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
14784         if ((_res & 1) != 0) return;
14785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14786         CHECK_ACCESS(_res_ptr);
14787         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
14788         FREE((void*)_res);
14789         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
14790 }
14791
14792 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
14793         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14794         CHECK_ACCESS(o_ptr);
14795         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
14796         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
14797         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14798         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
14799         return (uint32_t)ret_conv;
14800 }
14801
14802 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
14803         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14804         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
14805         return (uint32_t)ret_conv;
14806 }
14807
14808 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
14809         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
14810         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
14811         return ret_conv;
14812 }
14813
14814 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
14815         if ((_res & 1) != 0) return;
14816         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14817         CHECK_ACCESS(_res_ptr);
14818         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
14819         FREE((void*)_res);
14820         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
14821 }
14822
14823 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
14824         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14825         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
14826         return (uint32_t)ret_conv;
14827 }
14828 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
14829         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
14830         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
14831         return ret_conv;
14832 }
14833
14834 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
14835         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
14836         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14837         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
14838         return (uint32_t)ret_conv;
14839 }
14840
14841 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
14842         LDKSignature o_ref;
14843         CHECK(o->arr_len == 64);
14844         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
14845         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14846         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
14847         return (uint32_t)ret_conv;
14848 }
14849
14850 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
14851         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14852         *ret_conv = CResult_SignatureNoneZ_err();
14853         return (uint32_t)ret_conv;
14854 }
14855
14856 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
14857         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
14858         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
14859         return ret_conv;
14860 }
14861
14862 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
14863         if ((_res & 1) != 0) return;
14864         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14865         CHECK_ACCESS(_res_ptr);
14866         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
14867         FREE((void*)_res);
14868         CResult_SignatureNoneZ_free(_res_conv);
14869 }
14870
14871 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
14872         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14873         *ret_conv = CResult_SignatureNoneZ_clone(arg);
14874         return (uint32_t)ret_conv;
14875 }
14876 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
14877         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
14878         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
14879         return ret_conv;
14880 }
14881
14882 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
14883         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
14884         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14885         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
14886         return (uint32_t)ret_conv;
14887 }
14888
14889 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
14890         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14891         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
14892         return ((uint32_t)ret_conv);
14893 }
14894 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
14895         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
14896         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
14897         return ret_conv;
14898 }
14899
14900 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
14901         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
14902         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14903         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
14904         return ((uint32_t)ret_conv);
14905 }
14906
14907 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
14908         LDKSignature a_ref;
14909         CHECK(a->arr_len == 64);
14910         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14911         LDKSignature b_ref;
14912         CHECK(b->arr_len == 64);
14913         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
14914         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14915         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
14916         return ((uint32_t)ret_conv);
14917 }
14918
14919 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
14920         if ((_res & 1) != 0) return;
14921         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14922         CHECK_ACCESS(_res_ptr);
14923         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
14924         FREE((void*)_res);
14925         C2Tuple_SignatureSignatureZ_free(_res_conv);
14926 }
14927
14928 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
14929         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14930         CHECK_ACCESS(o_ptr);
14931         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
14932         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
14933         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14934         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
14935         return (uint32_t)ret_conv;
14936 }
14937
14938 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
14939         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14940         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
14941         return (uint32_t)ret_conv;
14942 }
14943
14944 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
14945         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
14946         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
14947         return ret_conv;
14948 }
14949
14950 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
14951         if ((_res & 1) != 0) return;
14952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14953         CHECK_ACCESS(_res_ptr);
14954         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
14955         FREE((void*)_res);
14956         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
14957 }
14958
14959 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
14960         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14961         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
14962         return (uint32_t)ret_conv;
14963 }
14964 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
14965         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
14966         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
14967         return ret_conv;
14968 }
14969
14970 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
14971         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
14972         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14973         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
14974         return (uint32_t)ret_conv;
14975 }
14976
14977 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
14978         LDKSecretKey o_ref;
14979         CHECK(o->arr_len == 32);
14980         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
14981         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14982         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
14983         return (uint32_t)ret_conv;
14984 }
14985
14986 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
14987         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14988         *ret_conv = CResult_SecretKeyNoneZ_err();
14989         return (uint32_t)ret_conv;
14990 }
14991
14992 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
14993         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
14994         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
14995         return ret_conv;
14996 }
14997
14998 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
14999         if ((_res & 1) != 0) return;
15000         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15001         CHECK_ACCESS(_res_ptr);
15002         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15003         FREE((void*)_res);
15004         CResult_SecretKeyNoneZ_free(_res_conv);
15005 }
15006
15007 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15008         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15009         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15010         return (uint32_t)ret_conv;
15011 }
15012 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
15013         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
15014         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15015         return ret_conv;
15016 }
15017
15018 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
15019         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
15020         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15021         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15022         return (uint32_t)ret_conv;
15023 }
15024
15025 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15026         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15027         CHECK_ACCESS(o_ptr);
15028         LDKSign o_conv = *(LDKSign*)(o_ptr);
15029         if (o_conv.free == LDKSign_JCalls_free) {
15030                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15031                 LDKSign_JCalls_cloned(&o_conv);
15032         }
15033         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15034         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15035         return (uint32_t)ret_conv;
15036 }
15037
15038 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15039         LDKDecodeError e_conv;
15040         e_conv.inner = (void*)(e & (~1));
15041         e_conv.is_owned = (e & 1) || (e == 0);
15042         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15043         e_conv = DecodeError_clone(&e_conv);
15044         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15045         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15046         return (uint32_t)ret_conv;
15047 }
15048
15049 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15050         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15051         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15052         return ret_conv;
15053 }
15054
15055 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15056         if ((_res & 1) != 0) return;
15057         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15058         CHECK_ACCESS(_res_ptr);
15059         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15060         FREE((void*)_res);
15061         CResult_SignDecodeErrorZ_free(_res_conv);
15062 }
15063
15064 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15065         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15066         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15067         return (uint32_t)ret_conv;
15068 }
15069 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15070         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15071         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15072         return ret_conv;
15073 }
15074
15075 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15076         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15077         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15078         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15079         return (uint32_t)ret_conv;
15080 }
15081
15082 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15083         LDKCVec_u5Z _res_constr;
15084         _res_constr.datalen = _res->arr_len;
15085         if (_res_constr.datalen > 0)
15086                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15087         else
15088                 _res_constr.data = NULL;
15089         int8_t* _res_vals = (void*) _res->elems;
15090         for (size_t h = 0; h < _res_constr.datalen; h++) {
15091                 int8_t _res_conv_7 = _res_vals[h];
15092                 
15093                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15094         }
15095         FREE(_res);
15096         CVec_u5Z_free(_res_constr);
15097 }
15098
15099 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15100         LDKRecoverableSignature o_ref;
15101         CHECK(o->arr_len == 68);
15102         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15103         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15104         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15105         return (uint32_t)ret_conv;
15106 }
15107
15108 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15109         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15110         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15111         return (uint32_t)ret_conv;
15112 }
15113
15114 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15115         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15116         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15117         return ret_conv;
15118 }
15119
15120 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15121         if ((_res & 1) != 0) return;
15122         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15123         CHECK_ACCESS(_res_ptr);
15124         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15125         FREE((void*)_res);
15126         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15127 }
15128
15129 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15130         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15131         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15132         return (uint32_t)ret_conv;
15133 }
15134 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15135         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15136         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15137         return ret_conv;
15138 }
15139
15140 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15141         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15142         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15143         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15144         return (uint32_t)ret_conv;
15145 }
15146
15147 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15148         LDKCVec_u8Z _res_ref;
15149         _res_ref.datalen = _res->arr_len;
15150         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15151         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15152         CVec_u8Z_free(_res_ref);
15153 }
15154
15155 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15156         LDKCVec_CVec_u8ZZ _res_constr;
15157         _res_constr.datalen = _res->arr_len;
15158         if (_res_constr.datalen > 0)
15159                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15160         else
15161                 _res_constr.data = NULL;
15162         int8_tArray* _res_vals = (void*) _res->elems;
15163         for (size_t m = 0; m < _res_constr.datalen; m++) {
15164                 int8_tArray _res_conv_12 = _res_vals[m];
15165                 LDKCVec_u8Z _res_conv_12_ref;
15166                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15167                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15168                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15169                 _res_constr.data[m] = _res_conv_12_ref;
15170         }
15171         FREE(_res);
15172         CVec_CVec_u8ZZ_free(_res_constr);
15173 }
15174
15175 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15176         LDKCVec_CVec_u8ZZ o_constr;
15177         o_constr.datalen = o->arr_len;
15178         if (o_constr.datalen > 0)
15179                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15180         else
15181                 o_constr.data = NULL;
15182         int8_tArray* o_vals = (void*) o->elems;
15183         for (size_t m = 0; m < o_constr.datalen; m++) {
15184                 int8_tArray o_conv_12 = o_vals[m];
15185                 LDKCVec_u8Z o_conv_12_ref;
15186                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15187                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15188                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15189                 o_constr.data[m] = o_conv_12_ref;
15190         }
15191         FREE(o);
15192         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15193         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15194         return (uint32_t)ret_conv;
15195 }
15196
15197 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15198         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15199         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15200         return (uint32_t)ret_conv;
15201 }
15202
15203 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15204         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15205         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15206         return ret_conv;
15207 }
15208
15209 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_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_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15214         FREE((void*)_res);
15215         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15216 }
15217
15218 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15219         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15220         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15221         return (uint32_t)ret_conv;
15222 }
15223 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15224         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15225         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15226         return ret_conv;
15227 }
15228
15229 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15230         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15231         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15232         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15233         return (uint32_t)ret_conv;
15234 }
15235
15236 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15237         LDKInMemorySigner o_conv;
15238         o_conv.inner = (void*)(o & (~1));
15239         o_conv.is_owned = (o & 1) || (o == 0);
15240         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15241         o_conv = InMemorySigner_clone(&o_conv);
15242         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15243         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15244         return (uint32_t)ret_conv;
15245 }
15246
15247 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15248         LDKDecodeError e_conv;
15249         e_conv.inner = (void*)(e & (~1));
15250         e_conv.is_owned = (e & 1) || (e == 0);
15251         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15252         e_conv = DecodeError_clone(&e_conv);
15253         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15254         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15255         return (uint32_t)ret_conv;
15256 }
15257
15258 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15259         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15260         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15261         return ret_conv;
15262 }
15263
15264 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15265         if ((_res & 1) != 0) return;
15266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15267         CHECK_ACCESS(_res_ptr);
15268         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15269         FREE((void*)_res);
15270         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15271 }
15272
15273 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15274         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15275         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15276         return (uint32_t)ret_conv;
15277 }
15278 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15279         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15280         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15281         return ret_conv;
15282 }
15283
15284 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15285         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15286         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15287         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15288         return (uint32_t)ret_conv;
15289 }
15290
15291 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15292         LDKCVec_TxOutZ _res_constr;
15293         _res_constr.datalen = _res->arr_len;
15294         if (_res_constr.datalen > 0)
15295                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15296         else
15297                 _res_constr.data = NULL;
15298         uint32_t* _res_vals = _res->elems;
15299         for (size_t h = 0; h < _res_constr.datalen; h++) {
15300                 uint32_t _res_conv_7 = _res_vals[h];
15301                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15302                 CHECK_ACCESS(_res_conv_7_ptr);
15303                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15304                 FREE((void*)_res_conv_7);
15305                 _res_constr.data[h] = _res_conv_7_conv;
15306         }
15307         FREE(_res);
15308         CVec_TxOutZ_free(_res_constr);
15309 }
15310
15311 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15312         LDKTransaction o_ref;
15313         o_ref.datalen = o->arr_len;
15314         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15315         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15316         o_ref.data_is_owned = true;
15317         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15318         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15319         return (uint32_t)ret_conv;
15320 }
15321
15322 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15323         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15324         *ret_conv = CResult_TransactionNoneZ_err();
15325         return (uint32_t)ret_conv;
15326 }
15327
15328 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15329         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15330         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15331         return ret_conv;
15332 }
15333
15334 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15335         if ((_res & 1) != 0) return;
15336         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15337         CHECK_ACCESS(_res_ptr);
15338         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15339         FREE((void*)_res);
15340         CResult_TransactionNoneZ_free(_res_conv);
15341 }
15342
15343 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15344         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15345         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15346         return (uint32_t)ret_conv;
15347 }
15348 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15349         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15350         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15351         return ret_conv;
15352 }
15353
15354 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15355         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15356         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15357         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15358         return (uint32_t)ret_conv;
15359 }
15360
15361 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15362         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15363         *ret_copy = COption_u16Z_some(o);
15364         uint32_t ret_ref = (uintptr_t)ret_copy;
15365         return ret_ref;
15366 }
15367
15368 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15369         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15370         *ret_copy = COption_u16Z_none();
15371         uint32_t ret_ref = (uintptr_t)ret_copy;
15372         return ret_ref;
15373 }
15374
15375 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15376         if ((_res & 1) != 0) return;
15377         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15378         CHECK_ACCESS(_res_ptr);
15379         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15380         FREE((void*)_res);
15381         COption_u16Z_free(_res_conv);
15382 }
15383
15384 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15385         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15386         *ret_copy = COption_u16Z_clone(arg);
15387 uint32_t ret_ref = (uintptr_t)ret_copy;
15388         return ret_ref;
15389 }
15390 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15391         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15392         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15393         return ret_conv;
15394 }
15395
15396 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15397         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15398         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15399         *ret_copy = COption_u16Z_clone(orig_conv);
15400         uint32_t ret_ref = (uintptr_t)ret_copy;
15401         return ret_ref;
15402 }
15403
15404 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15405         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15406         *ret_conv = CResult_NoneAPIErrorZ_ok();
15407         return (uint32_t)ret_conv;
15408 }
15409
15410 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15411         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15412         CHECK_ACCESS(e_ptr);
15413         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15414         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15415         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15416         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15417         return (uint32_t)ret_conv;
15418 }
15419
15420 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15421         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15422         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15423         return ret_conv;
15424 }
15425
15426 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15427         if ((_res & 1) != 0) return;
15428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15429         CHECK_ACCESS(_res_ptr);
15430         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15431         FREE((void*)_res);
15432         CResult_NoneAPIErrorZ_free(_res_conv);
15433 }
15434
15435 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15436         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15437         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15438         return (uint32_t)ret_conv;
15439 }
15440 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15441         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15442         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15443         return ret_conv;
15444 }
15445
15446 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15447         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15448         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15449         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15450         return (uint32_t)ret_conv;
15451 }
15452
15453 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15454         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15455         _res_constr.datalen = _res->arr_len;
15456         if (_res_constr.datalen > 0)
15457                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15458         else
15459                 _res_constr.data = NULL;
15460         uint32_t* _res_vals = _res->elems;
15461         for (size_t w = 0; w < _res_constr.datalen; w++) {
15462                 uint32_t _res_conv_22 = _res_vals[w];
15463                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15464                 CHECK_ACCESS(_res_conv_22_ptr);
15465                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15466                 FREE((void*)_res_conv_22);
15467                 _res_constr.data[w] = _res_conv_22_conv;
15468         }
15469         FREE(_res);
15470         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15471 }
15472
15473 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15474         LDKCVec_APIErrorZ _res_constr;
15475         _res_constr.datalen = _res->arr_len;
15476         if (_res_constr.datalen > 0)
15477                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15478         else
15479                 _res_constr.data = NULL;
15480         uint32_t* _res_vals = _res->elems;
15481         for (size_t k = 0; k < _res_constr.datalen; k++) {
15482                 uint32_t _res_conv_10 = _res_vals[k];
15483                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15484                 CHECK_ACCESS(_res_conv_10_ptr);
15485                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15486                 FREE((void*)_res_conv_10);
15487                 _res_constr.data[k] = _res_conv_10_conv;
15488         }
15489         FREE(_res);
15490         CVec_APIErrorZ_free(_res_constr);
15491 }
15492
15493 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15494         LDKThirtyTwoBytes o_ref;
15495         CHECK(o->arr_len == 32);
15496         memcpy(o_ref.data, o->elems, 32); FREE(o);
15497         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15498         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15499         return (uint32_t)ret_conv;
15500 }
15501
15502 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15503         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15504         CHECK_ACCESS(e_ptr);
15505         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15506         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15507         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15508         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15509         return (uint32_t)ret_conv;
15510 }
15511
15512 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15513         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15514         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15515         return ret_conv;
15516 }
15517
15518 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15519         if ((_res & 1) != 0) return;
15520         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15521         CHECK_ACCESS(_res_ptr);
15522         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15523         FREE((void*)_res);
15524         CResult__u832APIErrorZ_free(_res_conv);
15525 }
15526
15527 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15528         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15529         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15530         return (uint32_t)ret_conv;
15531 }
15532 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15533         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15534         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15535         return ret_conv;
15536 }
15537
15538 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15539         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15540         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15541         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15542         return (uint32_t)ret_conv;
15543 }
15544
15545 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15546         LDKThirtyTwoBytes o_ref;
15547         CHECK(o->arr_len == 32);
15548         memcpy(o_ref.data, o->elems, 32); FREE(o);
15549         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15550         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15551         return (uint32_t)ret_conv;
15552 }
15553
15554 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15555         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15556         CHECK_ACCESS(e_ptr);
15557         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15558         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15559         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15560         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15561         return (uint32_t)ret_conv;
15562 }
15563
15564 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15565         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15566         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15567         return ret_conv;
15568 }
15569
15570 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15571         if ((_res & 1) != 0) return;
15572         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15573         CHECK_ACCESS(_res_ptr);
15574         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15575         FREE((void*)_res);
15576         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15577 }
15578
15579 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15580         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15581         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15582         return (uint32_t)ret_conv;
15583 }
15584 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15585         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15586         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15587         return ret_conv;
15588 }
15589
15590 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15591         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15592         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15593         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15594         return (uint32_t)ret_conv;
15595 }
15596
15597 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15598         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15599         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15600         return (uint32_t)ret_conv;
15601 }
15602
15603 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15604         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15605         CHECK_ACCESS(e_ptr);
15606         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15607         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15608         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15609         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15610         return (uint32_t)ret_conv;
15611 }
15612
15613 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15614         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15615         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15616         return ret_conv;
15617 }
15618
15619 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15620         if ((_res & 1) != 0) return;
15621         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15622         CHECK_ACCESS(_res_ptr);
15623         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15624         FREE((void*)_res);
15625         CResult_NonePaymentSendFailureZ_free(_res_conv);
15626 }
15627
15628 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15629         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15630         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15631         return (uint32_t)ret_conv;
15632 }
15633 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15634         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15635         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15636         return ret_conv;
15637 }
15638
15639 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15640         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15641         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15642         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15643         return (uint32_t)ret_conv;
15644 }
15645
15646 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15647         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15648         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15649         return ((uint32_t)ret_conv);
15650 }
15651 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15652         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15653         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15654         return ret_conv;
15655 }
15656
15657 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15658         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15659         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15660         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15661         return ((uint32_t)ret_conv);
15662 }
15663
15664 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15665         LDKThirtyTwoBytes a_ref;
15666         CHECK(a->arr_len == 32);
15667         memcpy(a_ref.data, a->elems, 32); FREE(a);
15668         LDKThirtyTwoBytes b_ref;
15669         CHECK(b->arr_len == 32);
15670         memcpy(b_ref.data, b->elems, 32); FREE(b);
15671         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15672         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15673         return ((uint32_t)ret_conv);
15674 }
15675
15676 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15677         if ((_res & 1) != 0) return;
15678         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15679         CHECK_ACCESS(_res_ptr);
15680         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15681         FREE((void*)_res);
15682         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15683 }
15684
15685 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15686         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15687         CHECK_ACCESS(o_ptr);
15688         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15689         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
15690         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15691         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15692         return (uint32_t)ret_conv;
15693 }
15694
15695 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15696         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15697         CHECK_ACCESS(e_ptr);
15698         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15699         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15700         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15701         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15702         return (uint32_t)ret_conv;
15703 }
15704
15705 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15706         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15707         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15708         return ret_conv;
15709 }
15710
15711 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15712         if ((_res & 1) != 0) return;
15713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15714         CHECK_ACCESS(_res_ptr);
15715         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15716         FREE((void*)_res);
15717         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15718 }
15719
15720 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15721         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15722         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15723         return (uint32_t)ret_conv;
15724 }
15725 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15726         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15727         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15728         return ret_conv;
15729 }
15730
15731 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15732         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15733         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15734         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15735         return (uint32_t)ret_conv;
15736 }
15737
15738 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
15739         LDKCVec_ThirtyTwoBytesZ _res_constr;
15740         _res_constr.datalen = _res->arr_len;
15741         if (_res_constr.datalen > 0)
15742                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
15743         else
15744                 _res_constr.data = NULL;
15745         int8_tArray* _res_vals = (void*) _res->elems;
15746         for (size_t m = 0; m < _res_constr.datalen; m++) {
15747                 int8_tArray _res_conv_12 = _res_vals[m];
15748                 LDKThirtyTwoBytes _res_conv_12_ref;
15749                 CHECK(_res_conv_12->arr_len == 32);
15750                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
15751                 _res_constr.data[m] = _res_conv_12_ref;
15752         }
15753         FREE(_res);
15754         CVec_ThirtyTwoBytesZ_free(_res_constr);
15755 }
15756
15757 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15758         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15759         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15760         return ((uint32_t)ret_conv);
15761 }
15762 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15763         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15764         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15765         return ret_conv;
15766 }
15767
15768 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15769         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15770         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15771         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15772         return ((uint32_t)ret_conv);
15773 }
15774
15775 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
15776         LDKThirtyTwoBytes a_ref;
15777         CHECK(a->arr_len == 32);
15778         memcpy(a_ref.data, a->elems, 32); FREE(a);
15779         LDKThirtyTwoBytes b_ref;
15780         CHECK(b->arr_len == 32);
15781         memcpy(b_ref.data, b->elems, 32); FREE(b);
15782         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15783         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
15784         return ((uint32_t)ret_conv);
15785 }
15786
15787 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
15788         if ((_res & 1) != 0) return;
15789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15790         CHECK_ACCESS(_res_ptr);
15791         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
15792         FREE((void*)_res);
15793         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
15794 }
15795
15796 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
15797         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15798         CHECK_ACCESS(o_ptr);
15799         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15800         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15801         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15802         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
15803         return (uint32_t)ret_conv;
15804 }
15805
15806 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
15807         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15808         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
15809         return (uint32_t)ret_conv;
15810 }
15811
15812 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
15813         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
15814         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
15815         return ret_conv;
15816 }
15817
15818 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
15819         if ((_res & 1) != 0) return;
15820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15821         CHECK_ACCESS(_res_ptr);
15822         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
15823         FREE((void*)_res);
15824         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
15825 }
15826
15827 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
15828         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15829         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
15830         return (uint32_t)ret_conv;
15831 }
15832 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
15833         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
15834         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
15835         return ret_conv;
15836 }
15837
15838 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
15839         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
15840         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15841         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
15842         return (uint32_t)ret_conv;
15843 }
15844
15845 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
15846         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15847         CHECK_ACCESS(o_ptr);
15848         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15849         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15850         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15851         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
15852         return (uint32_t)ret_conv;
15853 }
15854
15855 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
15856         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15857         CHECK_ACCESS(e_ptr);
15858         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15859         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15860         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15861         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
15862         return (uint32_t)ret_conv;
15863 }
15864
15865 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
15866         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
15867         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
15868         return ret_conv;
15869 }
15870
15871 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
15872         if ((_res & 1) != 0) return;
15873         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15874         CHECK_ACCESS(_res_ptr);
15875         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
15876         FREE((void*)_res);
15877         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
15878 }
15879
15880 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
15881         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15882         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
15883         return (uint32_t)ret_conv;
15884 }
15885 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
15886         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
15887         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
15888         return ret_conv;
15889 }
15890
15891 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
15892         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
15893         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15894         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
15895         return (uint32_t)ret_conv;
15896 }
15897
15898 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
15899         LDKThirtyTwoBytes o_ref;
15900         CHECK(o->arr_len == 32);
15901         memcpy(o_ref.data, o->elems, 32); FREE(o);
15902         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15903         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
15904         return (uint32_t)ret_conv;
15905 }
15906
15907 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
15908         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15909         *ret_conv = CResult_PaymentSecretNoneZ_err();
15910         return (uint32_t)ret_conv;
15911 }
15912
15913 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
15914         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
15915         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
15916         return ret_conv;
15917 }
15918
15919 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
15920         if ((_res & 1) != 0) return;
15921         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15922         CHECK_ACCESS(_res_ptr);
15923         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
15924         FREE((void*)_res);
15925         CResult_PaymentSecretNoneZ_free(_res_conv);
15926 }
15927
15928 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
15929         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15930         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
15931         return (uint32_t)ret_conv;
15932 }
15933 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
15934         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
15935         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
15936         return ret_conv;
15937 }
15938
15939 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
15940         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
15941         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15942         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
15943         return (uint32_t)ret_conv;
15944 }
15945
15946 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
15947         LDKThirtyTwoBytes o_ref;
15948         CHECK(o->arr_len == 32);
15949         memcpy(o_ref.data, o->elems, 32); FREE(o);
15950         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15951         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
15952         return (uint32_t)ret_conv;
15953 }
15954
15955 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
15956         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15957         CHECK_ACCESS(e_ptr);
15958         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15959         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15960         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15961         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
15962         return (uint32_t)ret_conv;
15963 }
15964
15965 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
15966         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
15967         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
15968         return ret_conv;
15969 }
15970
15971 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
15972         if ((_res & 1) != 0) return;
15973         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15974         CHECK_ACCESS(_res_ptr);
15975         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
15976         FREE((void*)_res);
15977         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
15978 }
15979
15980 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
15981         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15982         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
15983         return (uint32_t)ret_conv;
15984 }
15985 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
15986         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
15987         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
15988         return ret_conv;
15989 }
15990
15991 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
15992         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
15993         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15994         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
15995         return (uint32_t)ret_conv;
15996 }
15997
15998 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
15999         LDKThirtyTwoBytes o_ref;
16000         CHECK(o->arr_len == 32);
16001         memcpy(o_ref.data, o->elems, 32); FREE(o);
16002         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16003         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16004         return (uint32_t)ret_conv;
16005 }
16006
16007 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16008         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16009         CHECK_ACCESS(e_ptr);
16010         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16011         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16012         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16013         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16014         return (uint32_t)ret_conv;
16015 }
16016
16017 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16018         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16019         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16020         return ret_conv;
16021 }
16022
16023 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16024         if ((_res & 1) != 0) return;
16025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16026         CHECK_ACCESS(_res_ptr);
16027         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16028         FREE((void*)_res);
16029         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16030 }
16031
16032 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16033         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16034         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16035         return (uint32_t)ret_conv;
16036 }
16037 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16038         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16039         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16040         return ret_conv;
16041 }
16042
16043 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16044         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16045         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16046         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16047         return (uint32_t)ret_conv;
16048 }
16049
16050 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
16051         LDKCounterpartyForwardingInfo o_conv;
16052         o_conv.inner = (void*)(o & (~1));
16053         o_conv.is_owned = (o & 1) || (o == 0);
16054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16055         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16056         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16057         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16058         return (uint32_t)ret_conv;
16059 }
16060
16061 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
16062         LDKDecodeError e_conv;
16063         e_conv.inner = (void*)(e & (~1));
16064         e_conv.is_owned = (e & 1) || (e == 0);
16065         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16066         e_conv = DecodeError_clone(&e_conv);
16067         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16068         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16069         return (uint32_t)ret_conv;
16070 }
16071
16072 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
16073         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
16074         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16075         return ret_conv;
16076 }
16077
16078 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
16079         if ((_res & 1) != 0) return;
16080         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16081         CHECK_ACCESS(_res_ptr);
16082         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16083         FREE((void*)_res);
16084         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16085 }
16086
16087 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16088         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16089         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16090         return (uint32_t)ret_conv;
16091 }
16092 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16093         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
16094         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16095         return ret_conv;
16096 }
16097
16098 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
16099         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
16100         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16101         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16102         return (uint32_t)ret_conv;
16103 }
16104
16105 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
16106         LDKChannelCounterparty o_conv;
16107         o_conv.inner = (void*)(o & (~1));
16108         o_conv.is_owned = (o & 1) || (o == 0);
16109         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16110         o_conv = ChannelCounterparty_clone(&o_conv);
16111         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16112         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16113         return (uint32_t)ret_conv;
16114 }
16115
16116 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
16117         LDKDecodeError e_conv;
16118         e_conv.inner = (void*)(e & (~1));
16119         e_conv.is_owned = (e & 1) || (e == 0);
16120         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16121         e_conv = DecodeError_clone(&e_conv);
16122         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16123         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16124         return (uint32_t)ret_conv;
16125 }
16126
16127 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
16128         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
16129         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16130         return ret_conv;
16131 }
16132
16133 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
16134         if ((_res & 1) != 0) return;
16135         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16136         CHECK_ACCESS(_res_ptr);
16137         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16138         FREE((void*)_res);
16139         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16140 }
16141
16142 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16143         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16144         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16145         return (uint32_t)ret_conv;
16146 }
16147 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
16148         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
16149         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16150         return ret_conv;
16151 }
16152
16153 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
16154         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
16155         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16156         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16157         return (uint32_t)ret_conv;
16158 }
16159
16160 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
16161         LDKChannelDetails o_conv;
16162         o_conv.inner = (void*)(o & (~1));
16163         o_conv.is_owned = (o & 1) || (o == 0);
16164         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16165         o_conv = ChannelDetails_clone(&o_conv);
16166         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16167         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16168         return (uint32_t)ret_conv;
16169 }
16170
16171 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
16172         LDKDecodeError e_conv;
16173         e_conv.inner = (void*)(e & (~1));
16174         e_conv.is_owned = (e & 1) || (e == 0);
16175         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16176         e_conv = DecodeError_clone(&e_conv);
16177         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16178         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16179         return (uint32_t)ret_conv;
16180 }
16181
16182 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
16183         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
16184         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16185         return ret_conv;
16186 }
16187
16188 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
16189         if ((_res & 1) != 0) return;
16190         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16191         CHECK_ACCESS(_res_ptr);
16192         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16193         FREE((void*)_res);
16194         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16195 }
16196
16197 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16198         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16199         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16200         return (uint32_t)ret_conv;
16201 }
16202 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
16203         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
16204         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16205         return ret_conv;
16206 }
16207
16208 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
16209         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
16210         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16211         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16212         return (uint32_t)ret_conv;
16213 }
16214
16215 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
16216         LDKPhantomRouteHints o_conv;
16217         o_conv.inner = (void*)(o & (~1));
16218         o_conv.is_owned = (o & 1) || (o == 0);
16219         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16220         o_conv = PhantomRouteHints_clone(&o_conv);
16221         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16222         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16223         return (uint32_t)ret_conv;
16224 }
16225
16226 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
16227         LDKDecodeError e_conv;
16228         e_conv.inner = (void*)(e & (~1));
16229         e_conv.is_owned = (e & 1) || (e == 0);
16230         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16231         e_conv = DecodeError_clone(&e_conv);
16232         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16233         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16234         return (uint32_t)ret_conv;
16235 }
16236
16237 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
16238         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
16239         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16240         return ret_conv;
16241 }
16242
16243 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
16244         if ((_res & 1) != 0) return;
16245         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16246         CHECK_ACCESS(_res_ptr);
16247         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16248         FREE((void*)_res);
16249         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16250 }
16251
16252 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16253         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16254         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16255         return (uint32_t)ret_conv;
16256 }
16257 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
16258         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
16259         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16260         return ret_conv;
16261 }
16262
16263 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
16264         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
16265         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16266         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16267         return (uint32_t)ret_conv;
16268 }
16269
16270 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16271         LDKCVec_ChannelMonitorZ _res_constr;
16272         _res_constr.datalen = _res->arr_len;
16273         if (_res_constr.datalen > 0)
16274                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16275         else
16276                 _res_constr.data = NULL;
16277         uint32_t* _res_vals = _res->elems;
16278         for (size_t q = 0; q < _res_constr.datalen; q++) {
16279                 uint32_t _res_conv_16 = _res_vals[q];
16280                 LDKChannelMonitor _res_conv_16_conv;
16281                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16282                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16283                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16284                 _res_constr.data[q] = _res_conv_16_conv;
16285         }
16286         FREE(_res);
16287         CVec_ChannelMonitorZ_free(_res_constr);
16288 }
16289
16290 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16291         LDKThirtyTwoBytes a_ref;
16292         CHECK(a->arr_len == 32);
16293         memcpy(a_ref.data, a->elems, 32); FREE(a);
16294         LDKChannelManager b_conv;
16295         b_conv.inner = (void*)(b & (~1));
16296         b_conv.is_owned = (b & 1) || (b == 0);
16297         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16298         // WARNING: we need a move here but no clone is available for LDKChannelManager
16299         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16300         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16301         return ((uint32_t)ret_conv);
16302 }
16303
16304 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16305         if ((_res & 1) != 0) return;
16306         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16307         CHECK_ACCESS(_res_ptr);
16308         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16309         FREE((void*)_res);
16310         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16311 }
16312
16313 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16314         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16315         CHECK_ACCESS(o_ptr);
16316         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16317         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16318         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16319         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16320         return (uint32_t)ret_conv;
16321 }
16322
16323 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16324         LDKDecodeError e_conv;
16325         e_conv.inner = (void*)(e & (~1));
16326         e_conv.is_owned = (e & 1) || (e == 0);
16327         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16328         e_conv = DecodeError_clone(&e_conv);
16329         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16330         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16331         return (uint32_t)ret_conv;
16332 }
16333
16334 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16335         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16336         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16337         return ret_conv;
16338 }
16339
16340 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16341         if ((_res & 1) != 0) return;
16342         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16343         CHECK_ACCESS(_res_ptr);
16344         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16345         FREE((void*)_res);
16346         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16347 }
16348
16349 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16350         LDKChannelConfig o_conv;
16351         o_conv.inner = (void*)(o & (~1));
16352         o_conv.is_owned = (o & 1) || (o == 0);
16353         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16354         o_conv = ChannelConfig_clone(&o_conv);
16355         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16356         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16357         return (uint32_t)ret_conv;
16358 }
16359
16360 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16361         LDKDecodeError e_conv;
16362         e_conv.inner = (void*)(e & (~1));
16363         e_conv.is_owned = (e & 1) || (e == 0);
16364         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16365         e_conv = DecodeError_clone(&e_conv);
16366         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16367         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16368         return (uint32_t)ret_conv;
16369 }
16370
16371 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16372         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16373         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16374         return ret_conv;
16375 }
16376
16377 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16378         if ((_res & 1) != 0) return;
16379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16380         CHECK_ACCESS(_res_ptr);
16381         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16382         FREE((void*)_res);
16383         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16384 }
16385
16386 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16387         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16388         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16389         return (uint32_t)ret_conv;
16390 }
16391 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16392         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16393         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16394         return ret_conv;
16395 }
16396
16397 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16398         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16399         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16400         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16401         return (uint32_t)ret_conv;
16402 }
16403
16404 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16405         LDKOutPoint o_conv;
16406         o_conv.inner = (void*)(o & (~1));
16407         o_conv.is_owned = (o & 1) || (o == 0);
16408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16409         o_conv = OutPoint_clone(&o_conv);
16410         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16411         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16412         return (uint32_t)ret_conv;
16413 }
16414
16415 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16416         LDKDecodeError e_conv;
16417         e_conv.inner = (void*)(e & (~1));
16418         e_conv.is_owned = (e & 1) || (e == 0);
16419         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16420         e_conv = DecodeError_clone(&e_conv);
16421         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16422         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16423         return (uint32_t)ret_conv;
16424 }
16425
16426 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16427         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16428         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16429         return ret_conv;
16430 }
16431
16432 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16433         if ((_res & 1) != 0) return;
16434         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16435         CHECK_ACCESS(_res_ptr);
16436         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16437         FREE((void*)_res);
16438         CResult_OutPointDecodeErrorZ_free(_res_conv);
16439 }
16440
16441 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16442         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16443         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16444         return (uint32_t)ret_conv;
16445 }
16446 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16447         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16448         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16449         return ret_conv;
16450 }
16451
16452 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16453         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16454         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16455         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16456         return (uint32_t)ret_conv;
16457 }
16458
16459 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16460         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16461         CHECK_ACCESS(o_ptr);
16462         LDKType o_conv = *(LDKType*)(o_ptr);
16463         if (o_conv.free == LDKType_JCalls_free) {
16464                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16465                 LDKType_JCalls_cloned(&o_conv);
16466         }
16467         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16468         *ret_copy = COption_TypeZ_some(o_conv);
16469         uint32_t ret_ref = (uintptr_t)ret_copy;
16470         return ret_ref;
16471 }
16472
16473 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16474         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16475         *ret_copy = COption_TypeZ_none();
16476         uint32_t ret_ref = (uintptr_t)ret_copy;
16477         return ret_ref;
16478 }
16479
16480 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16481         if ((_res & 1) != 0) return;
16482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16483         CHECK_ACCESS(_res_ptr);
16484         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16485         FREE((void*)_res);
16486         COption_TypeZ_free(_res_conv);
16487 }
16488
16489 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16490         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16491         *ret_copy = COption_TypeZ_clone(arg);
16492 uint32_t ret_ref = (uintptr_t)ret_copy;
16493         return ret_ref;
16494 }
16495 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16496         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16497         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16498         return ret_conv;
16499 }
16500
16501 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16502         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16503         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16504         *ret_copy = COption_TypeZ_clone(orig_conv);
16505         uint32_t ret_ref = (uintptr_t)ret_copy;
16506         return ret_ref;
16507 }
16508
16509 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16510         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16511         CHECK_ACCESS(o_ptr);
16512         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16513         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16514         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16515         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16516         return (uint32_t)ret_conv;
16517 }
16518
16519 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16520         LDKDecodeError e_conv;
16521         e_conv.inner = (void*)(e & (~1));
16522         e_conv.is_owned = (e & 1) || (e == 0);
16523         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16524         e_conv = DecodeError_clone(&e_conv);
16525         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16526         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16527         return (uint32_t)ret_conv;
16528 }
16529
16530 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16531         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16532         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16533         return ret_conv;
16534 }
16535
16536 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16537         if ((_res & 1) != 0) return;
16538         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16539         CHECK_ACCESS(_res_ptr);
16540         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16541         FREE((void*)_res);
16542         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16543 }
16544
16545 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16546         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16547         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16548         return (uint32_t)ret_conv;
16549 }
16550 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16551         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16552         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16553         return ret_conv;
16554 }
16555
16556 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16557         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16558         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16559         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16560         return (uint32_t)ret_conv;
16561 }
16562
16563 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16564         LDKThirtyTwoBytes o_ref;
16565         CHECK(o->arr_len == 32);
16566         memcpy(o_ref.data, o->elems, 32); FREE(o);
16567         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16568         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16569         return (uint32_t)ret_conv;
16570 }
16571
16572 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16573         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16574         CHECK_ACCESS(e_ptr);
16575         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16576         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16577         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16578         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16579         return (uint32_t)ret_conv;
16580 }
16581
16582 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16583         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16584         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16585         return ret_conv;
16586 }
16587
16588 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16589         if ((_res & 1) != 0) return;
16590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16591         CHECK_ACCESS(_res_ptr);
16592         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16593         FREE((void*)_res);
16594         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16595 }
16596
16597 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16598         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16599         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16600         return (uint32_t)ret_conv;
16601 }
16602 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
16603         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
16604         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
16605         return ret_conv;
16606 }
16607
16608 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
16609         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
16610         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16611         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
16612         return (uint32_t)ret_conv;
16613 }
16614
16615 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
16616         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
16617         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16618         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
16619         return (uint32_t)ret_conv;
16620 }
16621
16622 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
16623         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16624         CHECK_ACCESS(e_ptr);
16625         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16626         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16627         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16628         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
16629         return (uint32_t)ret_conv;
16630 }
16631
16632 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
16633         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
16634         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
16635         return ret_conv;
16636 }
16637
16638 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_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_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
16643         FREE((void*)_res);
16644         CResult_SiPrefixParseErrorZ_free(_res_conv);
16645 }
16646
16647 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
16648         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16649         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
16650         return (uint32_t)ret_conv;
16651 }
16652 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
16653         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
16654         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
16655         return ret_conv;
16656 }
16657
16658 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
16659         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
16660         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16661         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
16662         return (uint32_t)ret_conv;
16663 }
16664
16665 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
16666         LDKInvoice o_conv;
16667         o_conv.inner = (void*)(o & (~1));
16668         o_conv.is_owned = (o & 1) || (o == 0);
16669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16670         o_conv = Invoice_clone(&o_conv);
16671         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16672         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
16673         return (uint32_t)ret_conv;
16674 }
16675
16676 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
16677         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16678         CHECK_ACCESS(e_ptr);
16679         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
16680         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
16681         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16682         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
16683         return (uint32_t)ret_conv;
16684 }
16685
16686 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
16687         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
16688         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
16689         return ret_conv;
16690 }
16691
16692 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
16693         if ((_res & 1) != 0) return;
16694         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16695         CHECK_ACCESS(_res_ptr);
16696         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
16697         FREE((void*)_res);
16698         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
16699 }
16700
16701 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
16702         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16703         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
16704         return (uint32_t)ret_conv;
16705 }
16706 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
16707         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
16708         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
16709         return ret_conv;
16710 }
16711
16712 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
16713         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
16714         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16715         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
16716         return (uint32_t)ret_conv;
16717 }
16718
16719 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
16720         LDKSignedRawInvoice o_conv;
16721         o_conv.inner = (void*)(o & (~1));
16722         o_conv.is_owned = (o & 1) || (o == 0);
16723         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16724         o_conv = SignedRawInvoice_clone(&o_conv);
16725         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16726         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
16727         return (uint32_t)ret_conv;
16728 }
16729
16730 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
16731         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16732         CHECK_ACCESS(e_ptr);
16733         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16734         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16735         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16736         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
16737         return (uint32_t)ret_conv;
16738 }
16739
16740 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
16741         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
16742         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
16743         return ret_conv;
16744 }
16745
16746 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
16747         if ((_res & 1) != 0) return;
16748         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16749         CHECK_ACCESS(_res_ptr);
16750         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
16751         FREE((void*)_res);
16752         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
16753 }
16754
16755 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
16756         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16757         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
16758         return (uint32_t)ret_conv;
16759 }
16760 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
16761         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
16762         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
16763         return ret_conv;
16764 }
16765
16766 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
16767         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
16768         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16769         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
16770         return (uint32_t)ret_conv;
16771 }
16772
16773 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
16774         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16775         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
16776         return ((uint32_t)ret_conv);
16777 }
16778 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
16779         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
16780         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
16781         return ret_conv;
16782 }
16783
16784 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
16785         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
16786         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16787         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
16788         return ((uint32_t)ret_conv);
16789 }
16790
16791 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
16792         LDKRawInvoice a_conv;
16793         a_conv.inner = (void*)(a & (~1));
16794         a_conv.is_owned = (a & 1) || (a == 0);
16795         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16796         a_conv = RawInvoice_clone(&a_conv);
16797         LDKThirtyTwoBytes b_ref;
16798         CHECK(b->arr_len == 32);
16799         memcpy(b_ref.data, b->elems, 32); FREE(b);
16800         LDKInvoiceSignature c_conv;
16801         c_conv.inner = (void*)(c & (~1));
16802         c_conv.is_owned = (c & 1) || (c == 0);
16803         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16804         c_conv = InvoiceSignature_clone(&c_conv);
16805         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16806         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
16807         return ((uint32_t)ret_conv);
16808 }
16809
16810 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
16811         if ((_res & 1) != 0) return;
16812         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16813         CHECK_ACCESS(_res_ptr);
16814         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
16815         FREE((void*)_res);
16816         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
16817 }
16818
16819 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
16820         LDKPayeePubKey o_conv;
16821         o_conv.inner = (void*)(o & (~1));
16822         o_conv.is_owned = (o & 1) || (o == 0);
16823         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16824         o_conv = PayeePubKey_clone(&o_conv);
16825         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16826         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
16827         return (uint32_t)ret_conv;
16828 }
16829
16830 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
16831         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
16832         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16833         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
16834         return (uint32_t)ret_conv;
16835 }
16836
16837 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
16838         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
16839         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
16840         return ret_conv;
16841 }
16842
16843 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
16844         if ((_res & 1) != 0) return;
16845         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16846         CHECK_ACCESS(_res_ptr);
16847         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
16848         FREE((void*)_res);
16849         CResult_PayeePubKeyErrorZ_free(_res_conv);
16850 }
16851
16852 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
16853         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16854         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
16855         return (uint32_t)ret_conv;
16856 }
16857 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
16858         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
16859         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
16860         return ret_conv;
16861 }
16862
16863 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
16864         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
16865         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16866         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
16867         return (uint32_t)ret_conv;
16868 }
16869
16870 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
16871         LDKCVec_PrivateRouteZ _res_constr;
16872         _res_constr.datalen = _res->arr_len;
16873         if (_res_constr.datalen > 0)
16874                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
16875         else
16876                 _res_constr.data = NULL;
16877         uint32_t* _res_vals = _res->elems;
16878         for (size_t o = 0; o < _res_constr.datalen; o++) {
16879                 uint32_t _res_conv_14 = _res_vals[o];
16880                 LDKPrivateRoute _res_conv_14_conv;
16881                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16882                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16883                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16884                 _res_constr.data[o] = _res_conv_14_conv;
16885         }
16886         FREE(_res);
16887         CVec_PrivateRouteZ_free(_res_constr);
16888 }
16889
16890 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
16891         LDKPositiveTimestamp o_conv;
16892         o_conv.inner = (void*)(o & (~1));
16893         o_conv.is_owned = (o & 1) || (o == 0);
16894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16895         o_conv = PositiveTimestamp_clone(&o_conv);
16896         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16897         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
16898         return (uint32_t)ret_conv;
16899 }
16900
16901 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
16902         LDKCreationError e_conv = LDKCreationError_from_js(e);
16903         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16904         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
16905         return (uint32_t)ret_conv;
16906 }
16907
16908 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
16909         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
16910         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
16911         return ret_conv;
16912 }
16913
16914 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
16915         if ((_res & 1) != 0) return;
16916         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16917         CHECK_ACCESS(_res_ptr);
16918         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
16919         FREE((void*)_res);
16920         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
16921 }
16922
16923 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
16924         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16925         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
16926         return (uint32_t)ret_conv;
16927 }
16928 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
16929         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
16930         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
16931         return ret_conv;
16932 }
16933
16934 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
16935         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
16936         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16937         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
16938         return (uint32_t)ret_conv;
16939 }
16940
16941 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
16942         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16943         *ret_conv = CResult_NoneSemanticErrorZ_ok();
16944         return (uint32_t)ret_conv;
16945 }
16946
16947 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
16948         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
16949         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16950         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
16951         return (uint32_t)ret_conv;
16952 }
16953
16954 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
16955         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
16956         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
16957         return ret_conv;
16958 }
16959
16960 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
16961         if ((_res & 1) != 0) return;
16962         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16963         CHECK_ACCESS(_res_ptr);
16964         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
16965         FREE((void*)_res);
16966         CResult_NoneSemanticErrorZ_free(_res_conv);
16967 }
16968
16969 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
16970         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16971         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
16972         return (uint32_t)ret_conv;
16973 }
16974 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
16975         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
16976         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
16977         return ret_conv;
16978 }
16979
16980 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
16981         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
16982         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16983         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
16984         return (uint32_t)ret_conv;
16985 }
16986
16987 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
16988         LDKInvoice o_conv;
16989         o_conv.inner = (void*)(o & (~1));
16990         o_conv.is_owned = (o & 1) || (o == 0);
16991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16992         o_conv = Invoice_clone(&o_conv);
16993         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16994         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
16995         return (uint32_t)ret_conv;
16996 }
16997
16998 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
16999         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17000         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17001         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17002         return (uint32_t)ret_conv;
17003 }
17004
17005 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
17006         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17007         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17008         return ret_conv;
17009 }
17010
17011 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
17012         if ((_res & 1) != 0) return;
17013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17014         CHECK_ACCESS(_res_ptr);
17015         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17016         FREE((void*)_res);
17017         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17018 }
17019
17020 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17021         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17022         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17023         return (uint32_t)ret_conv;
17024 }
17025 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
17026         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17027         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17028         return ret_conv;
17029 }
17030
17031 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
17032         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17033         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17034         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17035         return (uint32_t)ret_conv;
17036 }
17037
17038 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
17039         LDKDescription o_conv;
17040         o_conv.inner = (void*)(o & (~1));
17041         o_conv.is_owned = (o & 1) || (o == 0);
17042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17043         o_conv = Description_clone(&o_conv);
17044         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17045         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17046         return (uint32_t)ret_conv;
17047 }
17048
17049 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17050         LDKCreationError e_conv = LDKCreationError_from_js(e);
17051         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17052         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17053         return (uint32_t)ret_conv;
17054 }
17055
17056 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
17057         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17058         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17059         return ret_conv;
17060 }
17061
17062 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
17063         if ((_res & 1) != 0) return;
17064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17065         CHECK_ACCESS(_res_ptr);
17066         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17067         FREE((void*)_res);
17068         CResult_DescriptionCreationErrorZ_free(_res_conv);
17069 }
17070
17071 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17072         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17073         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17074         return (uint32_t)ret_conv;
17075 }
17076 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
17077         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17078         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17079         return ret_conv;
17080 }
17081
17082 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
17083         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17084         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17085         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17086         return (uint32_t)ret_conv;
17087 }
17088
17089 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
17090         LDKPrivateRoute o_conv;
17091         o_conv.inner = (void*)(o & (~1));
17092         o_conv.is_owned = (o & 1) || (o == 0);
17093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17094         o_conv = PrivateRoute_clone(&o_conv);
17095         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17096         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17097         return (uint32_t)ret_conv;
17098 }
17099
17100 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17101         LDKCreationError e_conv = LDKCreationError_from_js(e);
17102         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17103         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17104         return (uint32_t)ret_conv;
17105 }
17106
17107 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
17108         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17109         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17110         return ret_conv;
17111 }
17112
17113 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
17114         if ((_res & 1) != 0) return;
17115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17116         CHECK_ACCESS(_res_ptr);
17117         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17118         FREE((void*)_res);
17119         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17120 }
17121
17122 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17123         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17124         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17125         return (uint32_t)ret_conv;
17126 }
17127 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
17128         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17129         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17130         return ret_conv;
17131 }
17132
17133 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
17134         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17135         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17136         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17137         return (uint32_t)ret_conv;
17138 }
17139
17140 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17141         LDKStr o_conv = str_ref_to_owned_c(o);
17142         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17143         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17144         return (uint32_t)ret_conv;
17145 }
17146
17147 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17148         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17149         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17150         *ret_conv = CResult_StringErrorZ_err(e_conv);
17151         return (uint32_t)ret_conv;
17152 }
17153
17154 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
17155         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17156         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17157         return ret_conv;
17158 }
17159
17160 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
17161         if ((_res & 1) != 0) return;
17162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17163         CHECK_ACCESS(_res_ptr);
17164         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17165         FREE((void*)_res);
17166         CResult_StringErrorZ_free(_res_conv);
17167 }
17168
17169 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17170         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17171         *ret_conv = CResult_StringErrorZ_clone(arg);
17172         return (uint32_t)ret_conv;
17173 }
17174 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
17175         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
17176         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17177         return ret_conv;
17178 }
17179
17180 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
17181         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
17182         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17183         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17184         return (uint32_t)ret_conv;
17185 }
17186
17187 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
17188         LDKChannelMonitorUpdate o_conv;
17189         o_conv.inner = (void*)(o & (~1));
17190         o_conv.is_owned = (o & 1) || (o == 0);
17191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17192         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17193         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17194         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17195         return (uint32_t)ret_conv;
17196 }
17197
17198 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
17199         LDKDecodeError e_conv;
17200         e_conv.inner = (void*)(e & (~1));
17201         e_conv.is_owned = (e & 1) || (e == 0);
17202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17203         e_conv = DecodeError_clone(&e_conv);
17204         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17205         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17206         return (uint32_t)ret_conv;
17207 }
17208
17209 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
17210         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17211         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17212         return ret_conv;
17213 }
17214
17215 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
17216         if ((_res & 1) != 0) return;
17217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17218         CHECK_ACCESS(_res_ptr);
17219         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17220         FREE((void*)_res);
17221         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17222 }
17223
17224 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17225         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17226         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17227         return (uint32_t)ret_conv;
17228 }
17229 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17230         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17231         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17232         return ret_conv;
17233 }
17234
17235 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
17236         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17237         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17238         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17239         return (uint32_t)ret_conv;
17240 }
17241
17242 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
17243         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17244         CHECK_ACCESS(o_ptr);
17245         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17246         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17247         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17248         *ret_copy = COption_MonitorEventZ_some(o_conv);
17249         uint32_t ret_ref = (uintptr_t)ret_copy;
17250         return ret_ref;
17251 }
17252
17253 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17254         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17255         *ret_copy = COption_MonitorEventZ_none();
17256         uint32_t ret_ref = (uintptr_t)ret_copy;
17257         return ret_ref;
17258 }
17259
17260 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
17261         if ((_res & 1) != 0) return;
17262         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17263         CHECK_ACCESS(_res_ptr);
17264         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17265         FREE((void*)_res);
17266         COption_MonitorEventZ_free(_res_conv);
17267 }
17268
17269 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17270         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17271         *ret_copy = COption_MonitorEventZ_clone(arg);
17272 uint32_t ret_ref = (uintptr_t)ret_copy;
17273         return ret_ref;
17274 }
17275 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
17276         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17277         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17278         return ret_conv;
17279 }
17280
17281 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
17282         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17283         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17284         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17285         uint32_t ret_ref = (uintptr_t)ret_copy;
17286         return ret_ref;
17287 }
17288
17289 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
17290         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17291         CHECK_ACCESS(o_ptr);
17292         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17293         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17294         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17295         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17296         return (uint32_t)ret_conv;
17297 }
17298
17299 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
17300         LDKDecodeError e_conv;
17301         e_conv.inner = (void*)(e & (~1));
17302         e_conv.is_owned = (e & 1) || (e == 0);
17303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17304         e_conv = DecodeError_clone(&e_conv);
17305         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17306         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17307         return (uint32_t)ret_conv;
17308 }
17309
17310 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
17311         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17312         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17313         return ret_conv;
17314 }
17315
17316 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17317         if ((_res & 1) != 0) return;
17318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17319         CHECK_ACCESS(_res_ptr);
17320         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17321         FREE((void*)_res);
17322         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17323 }
17324
17325 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17326         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17327         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17328         return (uint32_t)ret_conv;
17329 }
17330 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17331         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17332         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17333         return ret_conv;
17334 }
17335
17336 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17337         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17338         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17339         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17340         return (uint32_t)ret_conv;
17341 }
17342
17343 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17344         LDKHTLCUpdate o_conv;
17345         o_conv.inner = (void*)(o & (~1));
17346         o_conv.is_owned = (o & 1) || (o == 0);
17347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17348         o_conv = HTLCUpdate_clone(&o_conv);
17349         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17350         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17351         return (uint32_t)ret_conv;
17352 }
17353
17354 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17355         LDKDecodeError e_conv;
17356         e_conv.inner = (void*)(e & (~1));
17357         e_conv.is_owned = (e & 1) || (e == 0);
17358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17359         e_conv = DecodeError_clone(&e_conv);
17360         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17361         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17362         return (uint32_t)ret_conv;
17363 }
17364
17365 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17366         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17367         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17368         return ret_conv;
17369 }
17370
17371 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17372         if ((_res & 1) != 0) return;
17373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17374         CHECK_ACCESS(_res_ptr);
17375         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17376         FREE((void*)_res);
17377         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17378 }
17379
17380 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17381         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17382         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17383         return (uint32_t)ret_conv;
17384 }
17385 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17386         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17387         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17388         return ret_conv;
17389 }
17390
17391 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17392         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17393         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17394         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17395         return (uint32_t)ret_conv;
17396 }
17397
17398 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17399         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17400         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17401         return ((uint32_t)ret_conv);
17402 }
17403 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17404         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17405         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17406         return ret_conv;
17407 }
17408
17409 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17410         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17411         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17412         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17413         return ((uint32_t)ret_conv);
17414 }
17415
17416 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17417         LDKOutPoint a_conv;
17418         a_conv.inner = (void*)(a & (~1));
17419         a_conv.is_owned = (a & 1) || (a == 0);
17420         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17421         a_conv = OutPoint_clone(&a_conv);
17422         LDKCVec_u8Z b_ref;
17423         b_ref.datalen = b->arr_len;
17424         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17425         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17426         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17427         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17428         return ((uint32_t)ret_conv);
17429 }
17430
17431 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17432         if ((_res & 1) != 0) return;
17433         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17434         CHECK_ACCESS(_res_ptr);
17435         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17436         FREE((void*)_res);
17437         C2Tuple_OutPointScriptZ_free(_res_conv);
17438 }
17439
17440 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17441         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17442         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17443         return ((uint32_t)ret_conv);
17444 }
17445 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17446         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17447         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17448         return ret_conv;
17449 }
17450
17451 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17452         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17453         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17454         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17455         return ((uint32_t)ret_conv);
17456 }
17457
17458 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17459         LDKCVec_u8Z b_ref;
17460         b_ref.datalen = b->arr_len;
17461         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17462         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17463         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17464         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17465         return ((uint32_t)ret_conv);
17466 }
17467
17468 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
17469         if ((_res & 1) != 0) return;
17470         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17471         CHECK_ACCESS(_res_ptr);
17472         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17473         FREE((void*)_res);
17474         C2Tuple_u32ScriptZ_free(_res_conv);
17475 }
17476
17477 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17478         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17479         _res_constr.datalen = _res->arr_len;
17480         if (_res_constr.datalen > 0)
17481                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17482         else
17483                 _res_constr.data = NULL;
17484         uint32_t* _res_vals = _res->elems;
17485         for (size_t v = 0; v < _res_constr.datalen; v++) {
17486                 uint32_t _res_conv_21 = _res_vals[v];
17487                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17488                 CHECK_ACCESS(_res_conv_21_ptr);
17489                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17490                 FREE((void*)_res_conv_21);
17491                 _res_constr.data[v] = _res_conv_21_conv;
17492         }
17493         FREE(_res);
17494         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17495 }
17496
17497 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17498         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17499         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17500         return ((uint32_t)ret_conv);
17501 }
17502 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17503         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17504         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17505         return ret_conv;
17506 }
17507
17508 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17509         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17510         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17511         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17512         return ((uint32_t)ret_conv);
17513 }
17514
17515 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17516         LDKThirtyTwoBytes a_ref;
17517         CHECK(a->arr_len == 32);
17518         memcpy(a_ref.data, a->elems, 32); FREE(a);
17519         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17520         b_constr.datalen = b->arr_len;
17521         if (b_constr.datalen > 0)
17522                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17523         else
17524                 b_constr.data = NULL;
17525         uint32_t* b_vals = b->elems;
17526         for (size_t v = 0; v < b_constr.datalen; v++) {
17527                 uint32_t b_conv_21 = b_vals[v];
17528                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17529                 CHECK_ACCESS(b_conv_21_ptr);
17530                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17531                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17532                 b_constr.data[v] = b_conv_21_conv;
17533         }
17534         FREE(b);
17535         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17536         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17537         return ((uint32_t)ret_conv);
17538 }
17539
17540 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17541         if ((_res & 1) != 0) return;
17542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17543         CHECK_ACCESS(_res_ptr);
17544         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17545         FREE((void*)_res);
17546         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17547 }
17548
17549 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17550         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17551         _res_constr.datalen = _res->arr_len;
17552         if (_res_constr.datalen > 0)
17553                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17554         else
17555                 _res_constr.data = NULL;
17556         uint32_t* _res_vals = _res->elems;
17557         for (size_t o = 0; o < _res_constr.datalen; o++) {
17558                 uint32_t _res_conv_40 = _res_vals[o];
17559                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17560                 CHECK_ACCESS(_res_conv_40_ptr);
17561                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17562                 FREE((void*)_res_conv_40);
17563                 _res_constr.data[o] = _res_conv_40_conv;
17564         }
17565         FREE(_res);
17566         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17567 }
17568
17569 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17570         LDKCVec_EventZ _res_constr;
17571         _res_constr.datalen = _res->arr_len;
17572         if (_res_constr.datalen > 0)
17573                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17574         else
17575                 _res_constr.data = NULL;
17576         uint32_t* _res_vals = _res->elems;
17577         for (size_t h = 0; h < _res_constr.datalen; h++) {
17578                 uint32_t _res_conv_7 = _res_vals[h];
17579                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17580                 CHECK_ACCESS(_res_conv_7_ptr);
17581                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17582                 FREE((void*)_res_conv_7);
17583                 _res_constr.data[h] = _res_conv_7_conv;
17584         }
17585         FREE(_res);
17586         CVec_EventZ_free(_res_constr);
17587 }
17588
17589 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17590         LDKCVec_TransactionZ _res_constr;
17591         _res_constr.datalen = _res->arr_len;
17592         if (_res_constr.datalen > 0)
17593                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17594         else
17595                 _res_constr.data = NULL;
17596         int8_tArray* _res_vals = (void*) _res->elems;
17597         for (size_t m = 0; m < _res_constr.datalen; m++) {
17598                 int8_tArray _res_conv_12 = _res_vals[m];
17599                 LDKTransaction _res_conv_12_ref;
17600                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17601                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17602                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17603                 _res_conv_12_ref.data_is_owned = true;
17604                 _res_constr.data[m] = _res_conv_12_ref;
17605         }
17606         FREE(_res);
17607         CVec_TransactionZ_free(_res_constr);
17608 }
17609
17610 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
17611         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17612         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
17613         return ((uint32_t)ret_conv);
17614 }
17615 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
17616         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
17617         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
17618         return ret_conv;
17619 }
17620
17621 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
17622         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
17623         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17624         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
17625         return ((uint32_t)ret_conv);
17626 }
17627
17628 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
17629         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17630         CHECK_ACCESS(b_ptr);
17631         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
17632         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
17633         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17634         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
17635         return ((uint32_t)ret_conv);
17636 }
17637
17638 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
17639         if ((_res & 1) != 0) return;
17640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17641         CHECK_ACCESS(_res_ptr);
17642         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
17643         FREE((void*)_res);
17644         C2Tuple_u32TxOutZ_free(_res_conv);
17645 }
17646
17647 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
17648         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
17649         _res_constr.datalen = _res->arr_len;
17650         if (_res_constr.datalen > 0)
17651                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17652         else
17653                 _res_constr.data = NULL;
17654         uint32_t* _res_vals = _res->elems;
17655         for (size_t u = 0; u < _res_constr.datalen; u++) {
17656                 uint32_t _res_conv_20 = _res_vals[u];
17657                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
17658                 CHECK_ACCESS(_res_conv_20_ptr);
17659                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
17660                 FREE((void*)_res_conv_20);
17661                 _res_constr.data[u] = _res_conv_20_conv;
17662         }
17663         FREE(_res);
17664         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
17665 }
17666
17667 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
17668         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17669         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
17670         return ((uint32_t)ret_conv);
17671 }
17672 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
17673         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
17674         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
17675         return ret_conv;
17676 }
17677
17678 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
17679         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
17680         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17681         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
17682         return ((uint32_t)ret_conv);
17683 }
17684
17685 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
17686         LDKThirtyTwoBytes a_ref;
17687         CHECK(a->arr_len == 32);
17688         memcpy(a_ref.data, a->elems, 32); FREE(a);
17689         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
17690         b_constr.datalen = b->arr_len;
17691         if (b_constr.datalen > 0)
17692                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17693         else
17694                 b_constr.data = NULL;
17695         uint32_t* b_vals = b->elems;
17696         for (size_t u = 0; u < b_constr.datalen; u++) {
17697                 uint32_t b_conv_20 = b_vals[u];
17698                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
17699                 CHECK_ACCESS(b_conv_20_ptr);
17700                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
17701                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
17702                 b_constr.data[u] = b_conv_20_conv;
17703         }
17704         FREE(b);
17705         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17706         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
17707         return ((uint32_t)ret_conv);
17708 }
17709
17710 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
17711         if ((_res & 1) != 0) return;
17712         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17713         CHECK_ACCESS(_res_ptr);
17714         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
17715         FREE((void*)_res);
17716         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
17717 }
17718
17719 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
17720         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
17721         _res_constr.datalen = _res->arr_len;
17722         if (_res_constr.datalen > 0)
17723                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
17724         else
17725                 _res_constr.data = NULL;
17726         uint32_t* _res_vals = _res->elems;
17727         for (size_t n = 0; n < _res_constr.datalen; n++) {
17728                 uint32_t _res_conv_39 = _res_vals[n];
17729                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
17730                 CHECK_ACCESS(_res_conv_39_ptr);
17731                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
17732                 FREE((void*)_res_conv_39);
17733                 _res_constr.data[n] = _res_conv_39_conv;
17734         }
17735         FREE(_res);
17736         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
17737 }
17738
17739 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
17740         LDKCVec_BalanceZ _res_constr;
17741         _res_constr.datalen = _res->arr_len;
17742         if (_res_constr.datalen > 0)
17743                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
17744         else
17745                 _res_constr.data = NULL;
17746         uint32_t* _res_vals = _res->elems;
17747         for (size_t j = 0; j < _res_constr.datalen; j++) {
17748                 uint32_t _res_conv_9 = _res_vals[j];
17749                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
17750                 CHECK_ACCESS(_res_conv_9_ptr);
17751                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
17752                 FREE((void*)_res_conv_9);
17753                 _res_constr.data[j] = _res_conv_9_conv;
17754         }
17755         FREE(_res);
17756         CVec_BalanceZ_free(_res_constr);
17757 }
17758
17759 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17760         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17761         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17762         return ((uint32_t)ret_conv);
17763 }
17764 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
17765         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17766         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17767         return ret_conv;
17768 }
17769
17770 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
17771         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17772         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17773         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17774         return ((uint32_t)ret_conv);
17775 }
17776
17777 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
17778         LDKThirtyTwoBytes a_ref;
17779         CHECK(a->arr_len == 32);
17780         memcpy(a_ref.data, a->elems, 32); FREE(a);
17781         LDKChannelMonitor b_conv;
17782         b_conv.inner = (void*)(b & (~1));
17783         b_conv.is_owned = (b & 1) || (b == 0);
17784         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17785         b_conv = ChannelMonitor_clone(&b_conv);
17786         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17787         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17788         return ((uint32_t)ret_conv);
17789 }
17790
17791 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
17792         if ((_res & 1) != 0) return;
17793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17794         CHECK_ACCESS(_res_ptr);
17795         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17796         FREE((void*)_res);
17797         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17798 }
17799
17800 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
17801         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17802         CHECK_ACCESS(o_ptr);
17803         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
17804         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
17805         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17806         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
17807         return (uint32_t)ret_conv;
17808 }
17809
17810 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
17811         LDKDecodeError e_conv;
17812         e_conv.inner = (void*)(e & (~1));
17813         e_conv.is_owned = (e & 1) || (e == 0);
17814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17815         e_conv = DecodeError_clone(&e_conv);
17816         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17817         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
17818         return (uint32_t)ret_conv;
17819 }
17820
17821 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
17822         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
17823         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
17824         return ret_conv;
17825 }
17826
17827 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
17828         if ((_res & 1) != 0) return;
17829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17830         CHECK_ACCESS(_res_ptr);
17831         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
17832         FREE((void*)_res);
17833         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
17834 }
17835
17836 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
17837         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17838         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
17839         return (uint32_t)ret_conv;
17840 }
17841 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
17842         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
17843         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
17844         return ret_conv;
17845 }
17846
17847 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
17848         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
17849         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17850         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
17851         return (uint32_t)ret_conv;
17852 }
17853
17854 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
17855         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17856         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
17857         return ((uint32_t)ret_conv);
17858 }
17859 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
17860         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
17861         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
17862         return ret_conv;
17863 }
17864
17865 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
17866         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
17867         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17868         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
17869         return ((uint32_t)ret_conv);
17870 }
17871
17872 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
17873         LDKPublicKey a_ref;
17874         CHECK(a->arr_len == 33);
17875         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
17876         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17877         CHECK_ACCESS(b_ptr);
17878         LDKType b_conv = *(LDKType*)(b_ptr);
17879         if (b_conv.free == LDKType_JCalls_free) {
17880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17881                 LDKType_JCalls_cloned(&b_conv);
17882         }
17883         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17884         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
17885         return ((uint32_t)ret_conv);
17886 }
17887
17888 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
17889         if ((_res & 1) != 0) return;
17890         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17891         CHECK_ACCESS(_res_ptr);
17892         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
17893         FREE((void*)_res);
17894         C2Tuple_PublicKeyTypeZ_free(_res_conv);
17895 }
17896
17897 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
17898         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
17899         _res_constr.datalen = _res->arr_len;
17900         if (_res_constr.datalen > 0)
17901                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
17902         else
17903                 _res_constr.data = NULL;
17904         uint32_t* _res_vals = _res->elems;
17905         for (size_t z = 0; z < _res_constr.datalen; z++) {
17906                 uint32_t _res_conv_25 = _res_vals[z];
17907                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
17908                 CHECK_ACCESS(_res_conv_25_ptr);
17909                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
17910                 FREE((void*)_res_conv_25);
17911                 _res_constr.data[z] = _res_conv_25_conv;
17912         }
17913         FREE(_res);
17914         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
17915 }
17916
17917 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
17918         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17919         CHECK_ACCESS(o_ptr);
17920         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17921         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17922         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17923         *ret_copy = COption_NetAddressZ_some(o_conv);
17924         uint32_t ret_ref = (uintptr_t)ret_copy;
17925         return ret_ref;
17926 }
17927
17928 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
17929         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17930         *ret_copy = COption_NetAddressZ_none();
17931         uint32_t ret_ref = (uintptr_t)ret_copy;
17932         return ret_ref;
17933 }
17934
17935 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_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         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
17940         FREE((void*)_res);
17941         COption_NetAddressZ_free(_res_conv);
17942 }
17943
17944 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
17945         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17946         *ret_copy = COption_NetAddressZ_clone(arg);
17947 uint32_t ret_ref = (uintptr_t)ret_copy;
17948         return ret_ref;
17949 }
17950 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
17951         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
17952         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
17953         return ret_conv;
17954 }
17955
17956 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
17957         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
17958         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17959         *ret_copy = COption_NetAddressZ_clone(orig_conv);
17960         uint32_t ret_ref = (uintptr_t)ret_copy;
17961         return ret_ref;
17962 }
17963
17964 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
17965         LDKCVec_u8Z o_ref;
17966         o_ref.datalen = o->arr_len;
17967         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17968         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17969         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17970         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
17971         return (uint32_t)ret_conv;
17972 }
17973
17974 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
17975         LDKPeerHandleError e_conv;
17976         e_conv.inner = (void*)(e & (~1));
17977         e_conv.is_owned = (e & 1) || (e == 0);
17978         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17979         e_conv = PeerHandleError_clone(&e_conv);
17980         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17981         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
17982         return (uint32_t)ret_conv;
17983 }
17984
17985 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
17986         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
17987         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
17988         return ret_conv;
17989 }
17990
17991 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
17992         if ((_res & 1) != 0) return;
17993         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17994         CHECK_ACCESS(_res_ptr);
17995         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
17996         FREE((void*)_res);
17997         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
17998 }
17999
18000 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18001         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18002         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18003         return (uint32_t)ret_conv;
18004 }
18005 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18006         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18007         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18008         return ret_conv;
18009 }
18010
18011 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
18012         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18013         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18014         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18015         return (uint32_t)ret_conv;
18016 }
18017
18018 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18019         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18020         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18021         return (uint32_t)ret_conv;
18022 }
18023
18024 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
18025         LDKPeerHandleError e_conv;
18026         e_conv.inner = (void*)(e & (~1));
18027         e_conv.is_owned = (e & 1) || (e == 0);
18028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18029         e_conv = PeerHandleError_clone(&e_conv);
18030         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18031         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18032         return (uint32_t)ret_conv;
18033 }
18034
18035 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
18036         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18037         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18038         return ret_conv;
18039 }
18040
18041 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
18042         if ((_res & 1) != 0) return;
18043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18044         CHECK_ACCESS(_res_ptr);
18045         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18046         FREE((void*)_res);
18047         CResult_NonePeerHandleErrorZ_free(_res_conv);
18048 }
18049
18050 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18051         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18052         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18053         return (uint32_t)ret_conv;
18054 }
18055 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
18056         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18057         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18058         return ret_conv;
18059 }
18060
18061 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
18062         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18063         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18064         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18065         return (uint32_t)ret_conv;
18066 }
18067
18068 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18069         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18070         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18071         return (uint32_t)ret_conv;
18072 }
18073
18074 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
18075         LDKPeerHandleError e_conv;
18076         e_conv.inner = (void*)(e & (~1));
18077         e_conv.is_owned = (e & 1) || (e == 0);
18078         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18079         e_conv = PeerHandleError_clone(&e_conv);
18080         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18081         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18082         return (uint32_t)ret_conv;
18083 }
18084
18085 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
18086         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18087         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18088         return ret_conv;
18089 }
18090
18091 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
18092         if ((_res & 1) != 0) return;
18093         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18094         CHECK_ACCESS(_res_ptr);
18095         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18096         FREE((void*)_res);
18097         CResult_boolPeerHandleErrorZ_free(_res_conv);
18098 }
18099
18100 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18101         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18102         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18103         return (uint32_t)ret_conv;
18104 }
18105 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18106         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18107         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18108         return ret_conv;
18109 }
18110
18111 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
18112         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18113         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18114         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18115         return (uint32_t)ret_conv;
18116 }
18117
18118 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18119         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18120         *ret_conv = CResult_NoneErrorZ_ok();
18121         return (uint32_t)ret_conv;
18122 }
18123
18124 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18125         LDKIOError e_conv = LDKIOError_from_js(e);
18126         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18127         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18128         return (uint32_t)ret_conv;
18129 }
18130
18131 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
18132         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
18133         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18134         return ret_conv;
18135 }
18136
18137 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
18138         if ((_res & 1) != 0) return;
18139         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18140         CHECK_ACCESS(_res_ptr);
18141         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18142         FREE((void*)_res);
18143         CResult_NoneErrorZ_free(_res_conv);
18144 }
18145
18146 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18147         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18148         *ret_conv = CResult_NoneErrorZ_clone(arg);
18149         return (uint32_t)ret_conv;
18150 }
18151 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
18152         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
18153         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18154         return ret_conv;
18155 }
18156
18157 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
18158         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
18159         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18160         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18161         return (uint32_t)ret_conv;
18162 }
18163
18164 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
18165         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18166         CHECK_ACCESS(o_ptr);
18167         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18168         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18169         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18170         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18171         return (uint32_t)ret_conv;
18172 }
18173
18174 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
18175         LDKDecodeError e_conv;
18176         e_conv.inner = (void*)(e & (~1));
18177         e_conv.is_owned = (e & 1) || (e == 0);
18178         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18179         e_conv = DecodeError_clone(&e_conv);
18180         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18181         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18182         return (uint32_t)ret_conv;
18183 }
18184
18185 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
18186         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
18187         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18188         return ret_conv;
18189 }
18190
18191 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
18192         if ((_res & 1) != 0) return;
18193         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18194         CHECK_ACCESS(_res_ptr);
18195         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18196         FREE((void*)_res);
18197         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18198 }
18199
18200 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18201         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18202         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18203         return (uint32_t)ret_conv;
18204 }
18205 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
18206         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
18207         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18208         return ret_conv;
18209 }
18210
18211 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
18212         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
18213         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18214         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18215         return (uint32_t)ret_conv;
18216 }
18217
18218 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
18219         LDKCVec_UpdateAddHTLCZ _res_constr;
18220         _res_constr.datalen = _res->arr_len;
18221         if (_res_constr.datalen > 0)
18222                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18223         else
18224                 _res_constr.data = NULL;
18225         uint32_t* _res_vals = _res->elems;
18226         for (size_t p = 0; p < _res_constr.datalen; p++) {
18227                 uint32_t _res_conv_15 = _res_vals[p];
18228                 LDKUpdateAddHTLC _res_conv_15_conv;
18229                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
18230                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
18231                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18232                 _res_constr.data[p] = _res_conv_15_conv;
18233         }
18234         FREE(_res);
18235         CVec_UpdateAddHTLCZ_free(_res_constr);
18236 }
18237
18238 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
18239         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18240         _res_constr.datalen = _res->arr_len;
18241         if (_res_constr.datalen > 0)
18242                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18243         else
18244                 _res_constr.data = NULL;
18245         uint32_t* _res_vals = _res->elems;
18246         for (size_t t = 0; t < _res_constr.datalen; t++) {
18247                 uint32_t _res_conv_19 = _res_vals[t];
18248                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18249                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
18250                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
18251                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18252                 _res_constr.data[t] = _res_conv_19_conv;
18253         }
18254         FREE(_res);
18255         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18256 }
18257
18258 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
18259         LDKCVec_UpdateFailHTLCZ _res_constr;
18260         _res_constr.datalen = _res->arr_len;
18261         if (_res_constr.datalen > 0)
18262                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18263         else
18264                 _res_constr.data = NULL;
18265         uint32_t* _res_vals = _res->elems;
18266         for (size_t q = 0; q < _res_constr.datalen; q++) {
18267                 uint32_t _res_conv_16 = _res_vals[q];
18268                 LDKUpdateFailHTLC _res_conv_16_conv;
18269                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18270                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18271                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18272                 _res_constr.data[q] = _res_conv_16_conv;
18273         }
18274         FREE(_res);
18275         CVec_UpdateFailHTLCZ_free(_res_constr);
18276 }
18277
18278 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
18279         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18280         _res_constr.datalen = _res->arr_len;
18281         if (_res_constr.datalen > 0)
18282                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18283         else
18284                 _res_constr.data = NULL;
18285         uint32_t* _res_vals = _res->elems;
18286         for (size_t z = 0; z < _res_constr.datalen; z++) {
18287                 uint32_t _res_conv_25 = _res_vals[z];
18288                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18289                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18290                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18291                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18292                 _res_constr.data[z] = _res_conv_25_conv;
18293         }
18294         FREE(_res);
18295         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18296 }
18297
18298 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
18299         LDKAcceptChannel o_conv;
18300         o_conv.inner = (void*)(o & (~1));
18301         o_conv.is_owned = (o & 1) || (o == 0);
18302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18303         o_conv = AcceptChannel_clone(&o_conv);
18304         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18305         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18306         return (uint32_t)ret_conv;
18307 }
18308
18309 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
18310         LDKDecodeError e_conv;
18311         e_conv.inner = (void*)(e & (~1));
18312         e_conv.is_owned = (e & 1) || (e == 0);
18313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18314         e_conv = DecodeError_clone(&e_conv);
18315         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18316         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18317         return (uint32_t)ret_conv;
18318 }
18319
18320 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
18321         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18322         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18323         return ret_conv;
18324 }
18325
18326 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
18327         if ((_res & 1) != 0) return;
18328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18329         CHECK_ACCESS(_res_ptr);
18330         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18331         FREE((void*)_res);
18332         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18333 }
18334
18335 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18336         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18337         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18338         return (uint32_t)ret_conv;
18339 }
18340 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18341         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18342         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18343         return ret_conv;
18344 }
18345
18346 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18347         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18348         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18349         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18350         return (uint32_t)ret_conv;
18351 }
18352
18353 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18354         LDKAnnouncementSignatures o_conv;
18355         o_conv.inner = (void*)(o & (~1));
18356         o_conv.is_owned = (o & 1) || (o == 0);
18357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18358         o_conv = AnnouncementSignatures_clone(&o_conv);
18359         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18360         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18361         return (uint32_t)ret_conv;
18362 }
18363
18364 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18365         LDKDecodeError e_conv;
18366         e_conv.inner = (void*)(e & (~1));
18367         e_conv.is_owned = (e & 1) || (e == 0);
18368         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18369         e_conv = DecodeError_clone(&e_conv);
18370         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18371         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18372         return (uint32_t)ret_conv;
18373 }
18374
18375 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18376         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18377         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18378         return ret_conv;
18379 }
18380
18381 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18382         if ((_res & 1) != 0) return;
18383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18384         CHECK_ACCESS(_res_ptr);
18385         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18386         FREE((void*)_res);
18387         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18388 }
18389
18390 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18391         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18392         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18393         return (uint32_t)ret_conv;
18394 }
18395 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18396         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18397         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18398         return ret_conv;
18399 }
18400
18401 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18402         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18403         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18404         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18405         return (uint32_t)ret_conv;
18406 }
18407
18408 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18409         LDKChannelReestablish o_conv;
18410         o_conv.inner = (void*)(o & (~1));
18411         o_conv.is_owned = (o & 1) || (o == 0);
18412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18413         o_conv = ChannelReestablish_clone(&o_conv);
18414         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18415         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18420         LDKDecodeError 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 = DecodeError_clone(&e_conv);
18425         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18426         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18431         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18432         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18433         return ret_conv;
18434 }
18435
18436 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_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_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18441         FREE((void*)_res);
18442         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18443 }
18444
18445 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18446         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18447         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18448         return (uint32_t)ret_conv;
18449 }
18450 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18451         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18452         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18453         return ret_conv;
18454 }
18455
18456 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18457         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18458         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18459         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18460         return (uint32_t)ret_conv;
18461 }
18462
18463 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18464         LDKClosingSigned o_conv;
18465         o_conv.inner = (void*)(o & (~1));
18466         o_conv.is_owned = (o & 1) || (o == 0);
18467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18468         o_conv = ClosingSigned_clone(&o_conv);
18469         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18470         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18471         return (uint32_t)ret_conv;
18472 }
18473
18474 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18475         LDKDecodeError e_conv;
18476         e_conv.inner = (void*)(e & (~1));
18477         e_conv.is_owned = (e & 1) || (e == 0);
18478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18479         e_conv = DecodeError_clone(&e_conv);
18480         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18481         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18482         return (uint32_t)ret_conv;
18483 }
18484
18485 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18486         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18487         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18488         return ret_conv;
18489 }
18490
18491 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18492         if ((_res & 1) != 0) return;
18493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18494         CHECK_ACCESS(_res_ptr);
18495         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18496         FREE((void*)_res);
18497         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18498 }
18499
18500 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18501         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18502         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18503         return (uint32_t)ret_conv;
18504 }
18505 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18506         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18507         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18508         return ret_conv;
18509 }
18510
18511 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18512         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18513         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18514         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18515         return (uint32_t)ret_conv;
18516 }
18517
18518 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18519         LDKClosingSignedFeeRange o_conv;
18520         o_conv.inner = (void*)(o & (~1));
18521         o_conv.is_owned = (o & 1) || (o == 0);
18522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18523         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18524         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18525         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18526         return (uint32_t)ret_conv;
18527 }
18528
18529 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18530         LDKDecodeError e_conv;
18531         e_conv.inner = (void*)(e & (~1));
18532         e_conv.is_owned = (e & 1) || (e == 0);
18533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18534         e_conv = DecodeError_clone(&e_conv);
18535         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18536         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18537         return (uint32_t)ret_conv;
18538 }
18539
18540 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18541         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18542         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18543         return ret_conv;
18544 }
18545
18546 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18547         if ((_res & 1) != 0) return;
18548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18549         CHECK_ACCESS(_res_ptr);
18550         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18551         FREE((void*)_res);
18552         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18553 }
18554
18555 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18556         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18557         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18558         return (uint32_t)ret_conv;
18559 }
18560 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18561         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18562         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18563         return ret_conv;
18564 }
18565
18566 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18567         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18568         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18569         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18570         return (uint32_t)ret_conv;
18571 }
18572
18573 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18574         LDKCommitmentSigned o_conv;
18575         o_conv.inner = (void*)(o & (~1));
18576         o_conv.is_owned = (o & 1) || (o == 0);
18577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18578         o_conv = CommitmentSigned_clone(&o_conv);
18579         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18580         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18581         return (uint32_t)ret_conv;
18582 }
18583
18584 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18585         LDKDecodeError e_conv;
18586         e_conv.inner = (void*)(e & (~1));
18587         e_conv.is_owned = (e & 1) || (e == 0);
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18589         e_conv = DecodeError_clone(&e_conv);
18590         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18591         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18592         return (uint32_t)ret_conv;
18593 }
18594
18595 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18596         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18597         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18598         return ret_conv;
18599 }
18600
18601 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18602         if ((_res & 1) != 0) return;
18603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18604         CHECK_ACCESS(_res_ptr);
18605         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
18606         FREE((void*)_res);
18607         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
18608 }
18609
18610 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
18611         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18612         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
18613         return (uint32_t)ret_conv;
18614 }
18615 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18616         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
18617         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
18618         return ret_conv;
18619 }
18620
18621 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
18622         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
18623         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18624         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
18625         return (uint32_t)ret_conv;
18626 }
18627
18628 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
18629         LDKFundingCreated o_conv;
18630         o_conv.inner = (void*)(o & (~1));
18631         o_conv.is_owned = (o & 1) || (o == 0);
18632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18633         o_conv = FundingCreated_clone(&o_conv);
18634         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18635         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
18636         return (uint32_t)ret_conv;
18637 }
18638
18639 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
18640         LDKDecodeError e_conv;
18641         e_conv.inner = (void*)(e & (~1));
18642         e_conv.is_owned = (e & 1) || (e == 0);
18643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18644         e_conv = DecodeError_clone(&e_conv);
18645         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18646         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
18647         return (uint32_t)ret_conv;
18648 }
18649
18650 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
18651         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
18652         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
18653         return ret_conv;
18654 }
18655
18656 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
18657         if ((_res & 1) != 0) return;
18658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18659         CHECK_ACCESS(_res_ptr);
18660         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
18661         FREE((void*)_res);
18662         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
18663 }
18664
18665 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
18666         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18667         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
18668         return (uint32_t)ret_conv;
18669 }
18670 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
18671         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
18672         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
18673         return ret_conv;
18674 }
18675
18676 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
18677         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
18678         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18679         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
18680         return (uint32_t)ret_conv;
18681 }
18682
18683 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
18684         LDKFundingSigned o_conv;
18685         o_conv.inner = (void*)(o & (~1));
18686         o_conv.is_owned = (o & 1) || (o == 0);
18687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18688         o_conv = FundingSigned_clone(&o_conv);
18689         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18690         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
18691         return (uint32_t)ret_conv;
18692 }
18693
18694 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
18695         LDKDecodeError e_conv;
18696         e_conv.inner = (void*)(e & (~1));
18697         e_conv.is_owned = (e & 1) || (e == 0);
18698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18699         e_conv = DecodeError_clone(&e_conv);
18700         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18701         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
18702         return (uint32_t)ret_conv;
18703 }
18704
18705 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
18706         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
18707         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
18708         return ret_conv;
18709 }
18710
18711 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
18712         if ((_res & 1) != 0) return;
18713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18714         CHECK_ACCESS(_res_ptr);
18715         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
18716         FREE((void*)_res);
18717         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
18718 }
18719
18720 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
18721         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18722         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
18723         return (uint32_t)ret_conv;
18724 }
18725 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18726         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
18727         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
18728         return ret_conv;
18729 }
18730
18731 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
18732         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
18733         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18734         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
18735         return (uint32_t)ret_conv;
18736 }
18737
18738 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
18739         LDKChannelReady o_conv;
18740         o_conv.inner = (void*)(o & (~1));
18741         o_conv.is_owned = (o & 1) || (o == 0);
18742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18743         o_conv = ChannelReady_clone(&o_conv);
18744         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18745         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
18746         return (uint32_t)ret_conv;
18747 }
18748
18749 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
18750         LDKDecodeError e_conv;
18751         e_conv.inner = (void*)(e & (~1));
18752         e_conv.is_owned = (e & 1) || (e == 0);
18753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18754         e_conv = DecodeError_clone(&e_conv);
18755         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18756         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
18757         return (uint32_t)ret_conv;
18758 }
18759
18760 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
18761         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
18762         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
18763         return ret_conv;
18764 }
18765
18766 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
18767         if ((_res & 1) != 0) return;
18768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18769         CHECK_ACCESS(_res_ptr);
18770         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
18771         FREE((void*)_res);
18772         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
18773 }
18774
18775 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
18776         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18777         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
18778         return (uint32_t)ret_conv;
18779 }
18780 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
18781         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
18782         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
18783         return ret_conv;
18784 }
18785
18786 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
18787         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
18788         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18789         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
18790         return (uint32_t)ret_conv;
18791 }
18792
18793 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
18794         LDKInit o_conv;
18795         o_conv.inner = (void*)(o & (~1));
18796         o_conv.is_owned = (o & 1) || (o == 0);
18797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18798         o_conv = Init_clone(&o_conv);
18799         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18800         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
18801         return (uint32_t)ret_conv;
18802 }
18803
18804 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
18805         LDKDecodeError e_conv;
18806         e_conv.inner = (void*)(e & (~1));
18807         e_conv.is_owned = (e & 1) || (e == 0);
18808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18809         e_conv = DecodeError_clone(&e_conv);
18810         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18811         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18812         return (uint32_t)ret_conv;
18813 }
18814
18815 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
18816         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18817         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
18818         return ret_conv;
18819 }
18820
18821 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
18822         if ((_res & 1) != 0) return;
18823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18824         CHECK_ACCESS(_res_ptr);
18825         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18826         FREE((void*)_res);
18827         CResult_InitDecodeErrorZ_free(_res_conv);
18828 }
18829
18830 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18831         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18832         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18833         return (uint32_t)ret_conv;
18834 }
18835 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
18836         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18837         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18838         return ret_conv;
18839 }
18840
18841 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
18842         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18843         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18844         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18845         return (uint32_t)ret_conv;
18846 }
18847
18848 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
18849         LDKOpenChannel o_conv;
18850         o_conv.inner = (void*)(o & (~1));
18851         o_conv.is_owned = (o & 1) || (o == 0);
18852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18853         o_conv = OpenChannel_clone(&o_conv);
18854         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18855         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18856         return (uint32_t)ret_conv;
18857 }
18858
18859 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
18860         LDKDecodeError e_conv;
18861         e_conv.inner = (void*)(e & (~1));
18862         e_conv.is_owned = (e & 1) || (e == 0);
18863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18864         e_conv = DecodeError_clone(&e_conv);
18865         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18866         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18867         return (uint32_t)ret_conv;
18868 }
18869
18870 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18871         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18872         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18873         return ret_conv;
18874 }
18875
18876 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18877         if ((_res & 1) != 0) return;
18878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18879         CHECK_ACCESS(_res_ptr);
18880         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18881         FREE((void*)_res);
18882         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18883 }
18884
18885 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18886         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18887         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18888         return (uint32_t)ret_conv;
18889 }
18890 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18891         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18892         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18893         return ret_conv;
18894 }
18895
18896 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18897         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18898         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18899         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18900         return (uint32_t)ret_conv;
18901 }
18902
18903 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18904         LDKRevokeAndACK o_conv;
18905         o_conv.inner = (void*)(o & (~1));
18906         o_conv.is_owned = (o & 1) || (o == 0);
18907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18908         o_conv = RevokeAndACK_clone(&o_conv);
18909         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18910         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18911         return (uint32_t)ret_conv;
18912 }
18913
18914 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18915         LDKDecodeError e_conv;
18916         e_conv.inner = (void*)(e & (~1));
18917         e_conv.is_owned = (e & 1) || (e == 0);
18918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18919         e_conv = DecodeError_clone(&e_conv);
18920         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18921         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18922         return (uint32_t)ret_conv;
18923 }
18924
18925 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18926         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18927         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18928         return ret_conv;
18929 }
18930
18931 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18932         if ((_res & 1) != 0) return;
18933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18934         CHECK_ACCESS(_res_ptr);
18935         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18936         FREE((void*)_res);
18937         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18938 }
18939
18940 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18941         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18942         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18943         return (uint32_t)ret_conv;
18944 }
18945 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18946         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18947         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18948         return ret_conv;
18949 }
18950
18951 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18952         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18953         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18954         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18955         return (uint32_t)ret_conv;
18956 }
18957
18958 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18959         LDKShutdown o_conv;
18960         o_conv.inner = (void*)(o & (~1));
18961         o_conv.is_owned = (o & 1) || (o == 0);
18962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18963         o_conv = Shutdown_clone(&o_conv);
18964         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18965         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18966         return (uint32_t)ret_conv;
18967 }
18968
18969 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18970         LDKDecodeError e_conv;
18971         e_conv.inner = (void*)(e & (~1));
18972         e_conv.is_owned = (e & 1) || (e == 0);
18973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18974         e_conv = DecodeError_clone(&e_conv);
18975         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18976         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18977         return (uint32_t)ret_conv;
18978 }
18979
18980 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18981         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18982         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18983         return ret_conv;
18984 }
18985
18986 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18987         if ((_res & 1) != 0) return;
18988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18989         CHECK_ACCESS(_res_ptr);
18990         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18991         FREE((void*)_res);
18992         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18993 }
18994
18995 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18996         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18997         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18998         return (uint32_t)ret_conv;
18999 }
19000 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
19001         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
19002         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19003         return ret_conv;
19004 }
19005
19006 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
19007         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
19008         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19009         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19010         return (uint32_t)ret_conv;
19011 }
19012
19013 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
19014         LDKUpdateFailHTLC o_conv;
19015         o_conv.inner = (void*)(o & (~1));
19016         o_conv.is_owned = (o & 1) || (o == 0);
19017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19018         o_conv = UpdateFailHTLC_clone(&o_conv);
19019         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19020         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19021         return (uint32_t)ret_conv;
19022 }
19023
19024 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
19025         LDKDecodeError e_conv;
19026         e_conv.inner = (void*)(e & (~1));
19027         e_conv.is_owned = (e & 1) || (e == 0);
19028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19029         e_conv = DecodeError_clone(&e_conv);
19030         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19031         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19032         return (uint32_t)ret_conv;
19033 }
19034
19035 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
19036         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
19037         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19038         return ret_conv;
19039 }
19040
19041 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
19042         if ((_res & 1) != 0) return;
19043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19044         CHECK_ACCESS(_res_ptr);
19045         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19046         FREE((void*)_res);
19047         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19048 }
19049
19050 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19051         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19052         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19053         return (uint32_t)ret_conv;
19054 }
19055 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19056         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
19057         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19058         return ret_conv;
19059 }
19060
19061 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
19062         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
19063         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19064         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19065         return (uint32_t)ret_conv;
19066 }
19067
19068 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
19069         LDKUpdateFailMalformedHTLC o_conv;
19070         o_conv.inner = (void*)(o & (~1));
19071         o_conv.is_owned = (o & 1) || (o == 0);
19072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19073         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19074         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19075         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19076         return (uint32_t)ret_conv;
19077 }
19078
19079 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
19080         LDKDecodeError e_conv;
19081         e_conv.inner = (void*)(e & (~1));
19082         e_conv.is_owned = (e & 1) || (e == 0);
19083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19084         e_conv = DecodeError_clone(&e_conv);
19085         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19086         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19087         return (uint32_t)ret_conv;
19088 }
19089
19090 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
19091         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
19092         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19093         return ret_conv;
19094 }
19095
19096 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
19097         if ((_res & 1) != 0) return;
19098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19099         CHECK_ACCESS(_res_ptr);
19100         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19101         FREE((void*)_res);
19102         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19103 }
19104
19105 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19106         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19107         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19108         return (uint32_t)ret_conv;
19109 }
19110 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19111         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
19112         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19113         return ret_conv;
19114 }
19115
19116 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
19117         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
19118         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19119         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19120         return (uint32_t)ret_conv;
19121 }
19122
19123 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
19124         LDKUpdateFee o_conv;
19125         o_conv.inner = (void*)(o & (~1));
19126         o_conv.is_owned = (o & 1) || (o == 0);
19127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19128         o_conv = UpdateFee_clone(&o_conv);
19129         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19130         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19131         return (uint32_t)ret_conv;
19132 }
19133
19134 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
19135         LDKDecodeError e_conv;
19136         e_conv.inner = (void*)(e & (~1));
19137         e_conv.is_owned = (e & 1) || (e == 0);
19138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19139         e_conv = DecodeError_clone(&e_conv);
19140         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19141         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19142         return (uint32_t)ret_conv;
19143 }
19144
19145 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
19146         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
19147         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19148         return ret_conv;
19149 }
19150
19151 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
19152         if ((_res & 1) != 0) return;
19153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19154         CHECK_ACCESS(_res_ptr);
19155         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19156         FREE((void*)_res);
19157         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19158 }
19159
19160 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19161         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19162         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19163         return (uint32_t)ret_conv;
19164 }
19165 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
19166         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
19167         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19168         return ret_conv;
19169 }
19170
19171 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
19172         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
19173         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19174         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19175         return (uint32_t)ret_conv;
19176 }
19177
19178 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
19179         LDKUpdateFulfillHTLC o_conv;
19180         o_conv.inner = (void*)(o & (~1));
19181         o_conv.is_owned = (o & 1) || (o == 0);
19182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19183         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19184         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19185         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19186         return (uint32_t)ret_conv;
19187 }
19188
19189 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
19190         LDKDecodeError e_conv;
19191         e_conv.inner = (void*)(e & (~1));
19192         e_conv.is_owned = (e & 1) || (e == 0);
19193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19194         e_conv = DecodeError_clone(&e_conv);
19195         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19196         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19197         return (uint32_t)ret_conv;
19198 }
19199
19200 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
19201         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
19202         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19203         return ret_conv;
19204 }
19205
19206 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
19207         if ((_res & 1) != 0) return;
19208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19209         CHECK_ACCESS(_res_ptr);
19210         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19211         FREE((void*)_res);
19212         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19213 }
19214
19215 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19216         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19217         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19218         return (uint32_t)ret_conv;
19219 }
19220 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19221         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
19222         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19223         return ret_conv;
19224 }
19225
19226 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
19227         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
19228         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19229         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19230         return (uint32_t)ret_conv;
19231 }
19232
19233 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
19234         LDKUpdateAddHTLC o_conv;
19235         o_conv.inner = (void*)(o & (~1));
19236         o_conv.is_owned = (o & 1) || (o == 0);
19237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19238         o_conv = UpdateAddHTLC_clone(&o_conv);
19239         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19240         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19241         return (uint32_t)ret_conv;
19242 }
19243
19244 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
19245         LDKDecodeError e_conv;
19246         e_conv.inner = (void*)(e & (~1));
19247         e_conv.is_owned = (e & 1) || (e == 0);
19248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19249         e_conv = DecodeError_clone(&e_conv);
19250         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19251         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19252         return (uint32_t)ret_conv;
19253 }
19254
19255 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
19256         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
19257         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19258         return ret_conv;
19259 }
19260
19261 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
19262         if ((_res & 1) != 0) return;
19263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19264         CHECK_ACCESS(_res_ptr);
19265         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19266         FREE((void*)_res);
19267         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19268 }
19269
19270 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19271         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19272         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19273         return (uint32_t)ret_conv;
19274 }
19275 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19276         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
19277         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19278         return ret_conv;
19279 }
19280
19281 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
19282         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
19283         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19284         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19285         return (uint32_t)ret_conv;
19286 }
19287
19288 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
19289         LDKPing o_conv;
19290         o_conv.inner = (void*)(o & (~1));
19291         o_conv.is_owned = (o & 1) || (o == 0);
19292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19293         o_conv = Ping_clone(&o_conv);
19294         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19295         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19296         return (uint32_t)ret_conv;
19297 }
19298
19299 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
19300         LDKDecodeError e_conv;
19301         e_conv.inner = (void*)(e & (~1));
19302         e_conv.is_owned = (e & 1) || (e == 0);
19303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19304         e_conv = DecodeError_clone(&e_conv);
19305         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19306         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19307         return (uint32_t)ret_conv;
19308 }
19309
19310 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
19311         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19312         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19313         return ret_conv;
19314 }
19315
19316 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
19317         if ((_res & 1) != 0) return;
19318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19319         CHECK_ACCESS(_res_ptr);
19320         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19321         FREE((void*)_res);
19322         CResult_PingDecodeErrorZ_free(_res_conv);
19323 }
19324
19325 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19326         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19327         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19328         return (uint32_t)ret_conv;
19329 }
19330 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19331         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19332         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19333         return ret_conv;
19334 }
19335
19336 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19337         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19338         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19339         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19340         return (uint32_t)ret_conv;
19341 }
19342
19343 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19344         LDKPong o_conv;
19345         o_conv.inner = (void*)(o & (~1));
19346         o_conv.is_owned = (o & 1) || (o == 0);
19347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19348         o_conv = Pong_clone(&o_conv);
19349         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19350         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19351         return (uint32_t)ret_conv;
19352 }
19353
19354 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19355         LDKDecodeError e_conv;
19356         e_conv.inner = (void*)(e & (~1));
19357         e_conv.is_owned = (e & 1) || (e == 0);
19358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19359         e_conv = DecodeError_clone(&e_conv);
19360         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19361         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19362         return (uint32_t)ret_conv;
19363 }
19364
19365 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19366         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19367         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19368         return ret_conv;
19369 }
19370
19371 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19372         if ((_res & 1) != 0) return;
19373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19374         CHECK_ACCESS(_res_ptr);
19375         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19376         FREE((void*)_res);
19377         CResult_PongDecodeErrorZ_free(_res_conv);
19378 }
19379
19380 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19381         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19382         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19383         return (uint32_t)ret_conv;
19384 }
19385 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19386         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19387         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19388         return ret_conv;
19389 }
19390
19391 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19392         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19393         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19394         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19395         return (uint32_t)ret_conv;
19396 }
19397
19398 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19399         LDKUnsignedChannelAnnouncement o_conv;
19400         o_conv.inner = (void*)(o & (~1));
19401         o_conv.is_owned = (o & 1) || (o == 0);
19402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19403         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19404         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19405         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19406         return (uint32_t)ret_conv;
19407 }
19408
19409 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19410         LDKDecodeError e_conv;
19411         e_conv.inner = (void*)(e & (~1));
19412         e_conv.is_owned = (e & 1) || (e == 0);
19413         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19414         e_conv = DecodeError_clone(&e_conv);
19415         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19416         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19417         return (uint32_t)ret_conv;
19418 }
19419
19420 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19421         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19422         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19423         return ret_conv;
19424 }
19425
19426 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19427         if ((_res & 1) != 0) return;
19428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19429         CHECK_ACCESS(_res_ptr);
19430         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19431         FREE((void*)_res);
19432         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19433 }
19434
19435 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19436         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19437         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19438         return (uint32_t)ret_conv;
19439 }
19440 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19441         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19442         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19443         return ret_conv;
19444 }
19445
19446 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19447         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19448         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19449         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19450         return (uint32_t)ret_conv;
19451 }
19452
19453 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19454         LDKChannelAnnouncement o_conv;
19455         o_conv.inner = (void*)(o & (~1));
19456         o_conv.is_owned = (o & 1) || (o == 0);
19457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19458         o_conv = ChannelAnnouncement_clone(&o_conv);
19459         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19460         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19461         return (uint32_t)ret_conv;
19462 }
19463
19464 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19465         LDKDecodeError e_conv;
19466         e_conv.inner = (void*)(e & (~1));
19467         e_conv.is_owned = (e & 1) || (e == 0);
19468         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19469         e_conv = DecodeError_clone(&e_conv);
19470         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19471         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19472         return (uint32_t)ret_conv;
19473 }
19474
19475 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19476         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19477         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19478         return ret_conv;
19479 }
19480
19481 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19482         if ((_res & 1) != 0) return;
19483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19484         CHECK_ACCESS(_res_ptr);
19485         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19486         FREE((void*)_res);
19487         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19488 }
19489
19490 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19491         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19492         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19493         return (uint32_t)ret_conv;
19494 }
19495 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19496         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19497         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19498         return ret_conv;
19499 }
19500
19501 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19502         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19503         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19504         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19505         return (uint32_t)ret_conv;
19506 }
19507
19508 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19509         LDKUnsignedChannelUpdate o_conv;
19510         o_conv.inner = (void*)(o & (~1));
19511         o_conv.is_owned = (o & 1) || (o == 0);
19512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19513         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19514         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19515         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19516         return (uint32_t)ret_conv;
19517 }
19518
19519 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19520         LDKDecodeError e_conv;
19521         e_conv.inner = (void*)(e & (~1));
19522         e_conv.is_owned = (e & 1) || (e == 0);
19523         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19524         e_conv = DecodeError_clone(&e_conv);
19525         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19526         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19527         return (uint32_t)ret_conv;
19528 }
19529
19530 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19531         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19532         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19533         return ret_conv;
19534 }
19535
19536 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19537         if ((_res & 1) != 0) return;
19538         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19539         CHECK_ACCESS(_res_ptr);
19540         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19541         FREE((void*)_res);
19542         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19543 }
19544
19545 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19546         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19547         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19548         return (uint32_t)ret_conv;
19549 }
19550 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19551         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19552         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19553         return ret_conv;
19554 }
19555
19556 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19557         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19558         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19559         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19560         return (uint32_t)ret_conv;
19561 }
19562
19563 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19564         LDKChannelUpdate o_conv;
19565         o_conv.inner = (void*)(o & (~1));
19566         o_conv.is_owned = (o & 1) || (o == 0);
19567         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19568         o_conv = ChannelUpdate_clone(&o_conv);
19569         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19570         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19571         return (uint32_t)ret_conv;
19572 }
19573
19574 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19575         LDKDecodeError e_conv;
19576         e_conv.inner = (void*)(e & (~1));
19577         e_conv.is_owned = (e & 1) || (e == 0);
19578         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19579         e_conv = DecodeError_clone(&e_conv);
19580         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19581         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19582         return (uint32_t)ret_conv;
19583 }
19584
19585 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19586         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19587         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19588         return ret_conv;
19589 }
19590
19591 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19592         if ((_res & 1) != 0) return;
19593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19594         CHECK_ACCESS(_res_ptr);
19595         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19596         FREE((void*)_res);
19597         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19598 }
19599
19600 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19601         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19602         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19603         return (uint32_t)ret_conv;
19604 }
19605 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19606         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
19607         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19608         return ret_conv;
19609 }
19610
19611 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19612         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
19613         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19614         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
19615         return (uint32_t)ret_conv;
19616 }
19617
19618 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
19619         LDKErrorMessage o_conv;
19620         o_conv.inner = (void*)(o & (~1));
19621         o_conv.is_owned = (o & 1) || (o == 0);
19622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19623         o_conv = ErrorMessage_clone(&o_conv);
19624         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19625         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
19626         return (uint32_t)ret_conv;
19627 }
19628
19629 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
19630         LDKDecodeError e_conv;
19631         e_conv.inner = (void*)(e & (~1));
19632         e_conv.is_owned = (e & 1) || (e == 0);
19633         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19634         e_conv = DecodeError_clone(&e_conv);
19635         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19636         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
19637         return (uint32_t)ret_conv;
19638 }
19639
19640 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
19641         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
19642         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
19643         return ret_conv;
19644 }
19645
19646 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
19647         if ((_res & 1) != 0) return;
19648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19649         CHECK_ACCESS(_res_ptr);
19650         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
19651         FREE((void*)_res);
19652         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
19653 }
19654
19655 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
19656         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19657         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
19658         return (uint32_t)ret_conv;
19659 }
19660 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19661         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
19662         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
19663         return ret_conv;
19664 }
19665
19666 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
19667         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
19668         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19669         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
19670         return (uint32_t)ret_conv;
19671 }
19672
19673 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
19674         LDKWarningMessage o_conv;
19675         o_conv.inner = (void*)(o & (~1));
19676         o_conv.is_owned = (o & 1) || (o == 0);
19677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19678         o_conv = WarningMessage_clone(&o_conv);
19679         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19680         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
19681         return (uint32_t)ret_conv;
19682 }
19683
19684 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
19685         LDKDecodeError e_conv;
19686         e_conv.inner = (void*)(e & (~1));
19687         e_conv.is_owned = (e & 1) || (e == 0);
19688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19689         e_conv = DecodeError_clone(&e_conv);
19690         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19691         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
19692         return (uint32_t)ret_conv;
19693 }
19694
19695 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
19696         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
19697         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
19698         return ret_conv;
19699 }
19700
19701 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
19702         if ((_res & 1) != 0) return;
19703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19704         CHECK_ACCESS(_res_ptr);
19705         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
19706         FREE((void*)_res);
19707         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
19708 }
19709
19710 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
19711         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19712         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
19713         return (uint32_t)ret_conv;
19714 }
19715 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19716         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
19717         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
19718         return ret_conv;
19719 }
19720
19721 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
19722         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
19723         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19724         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
19725         return (uint32_t)ret_conv;
19726 }
19727
19728 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19729         LDKUnsignedNodeAnnouncement o_conv;
19730         o_conv.inner = (void*)(o & (~1));
19731         o_conv.is_owned = (o & 1) || (o == 0);
19732         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19733         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
19734         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19735         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
19736         return (uint32_t)ret_conv;
19737 }
19738
19739 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19740         LDKDecodeError e_conv;
19741         e_conv.inner = (void*)(e & (~1));
19742         e_conv.is_owned = (e & 1) || (e == 0);
19743         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19744         e_conv = DecodeError_clone(&e_conv);
19745         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19746         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
19747         return (uint32_t)ret_conv;
19748 }
19749
19750 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19751         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
19752         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19753         return ret_conv;
19754 }
19755
19756 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19757         if ((_res & 1) != 0) return;
19758         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19759         CHECK_ACCESS(_res_ptr);
19760         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
19761         FREE((void*)_res);
19762         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
19763 }
19764
19765 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19766         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19767         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
19768         return (uint32_t)ret_conv;
19769 }
19770 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19771         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
19772         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19773         return ret_conv;
19774 }
19775
19776 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19777         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
19778         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19779         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
19780         return (uint32_t)ret_conv;
19781 }
19782
19783 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19784         LDKNodeAnnouncement o_conv;
19785         o_conv.inner = (void*)(o & (~1));
19786         o_conv.is_owned = (o & 1) || (o == 0);
19787         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19788         o_conv = NodeAnnouncement_clone(&o_conv);
19789         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19790         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
19791         return (uint32_t)ret_conv;
19792 }
19793
19794 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19795         LDKDecodeError e_conv;
19796         e_conv.inner = (void*)(e & (~1));
19797         e_conv.is_owned = (e & 1) || (e == 0);
19798         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19799         e_conv = DecodeError_clone(&e_conv);
19800         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19801         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
19802         return (uint32_t)ret_conv;
19803 }
19804
19805 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19806         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
19807         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19808         return ret_conv;
19809 }
19810
19811 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19812         if ((_res & 1) != 0) return;
19813         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19814         CHECK_ACCESS(_res_ptr);
19815         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19816         FREE((void*)_res);
19817         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19818 }
19819
19820 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19821         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19822         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19823         return (uint32_t)ret_conv;
19824 }
19825 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19826         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19827         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19828         return ret_conv;
19829 }
19830
19831 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19832         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19833         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19834         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19835         return (uint32_t)ret_conv;
19836 }
19837
19838 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
19839         LDKQueryShortChannelIds o_conv;
19840         o_conv.inner = (void*)(o & (~1));
19841         o_conv.is_owned = (o & 1) || (o == 0);
19842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19843         o_conv = QueryShortChannelIds_clone(&o_conv);
19844         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19845         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19846         return (uint32_t)ret_conv;
19847 }
19848
19849 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
19850         LDKDecodeError e_conv;
19851         e_conv.inner = (void*)(e & (~1));
19852         e_conv.is_owned = (e & 1) || (e == 0);
19853         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19854         e_conv = DecodeError_clone(&e_conv);
19855         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19856         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19857         return (uint32_t)ret_conv;
19858 }
19859
19860 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
19861         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19862         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19863         return ret_conv;
19864 }
19865
19866 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
19867         if ((_res & 1) != 0) return;
19868         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19869         CHECK_ACCESS(_res_ptr);
19870         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19871         FREE((void*)_res);
19872         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19873 }
19874
19875 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19876         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19877         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19878         return (uint32_t)ret_conv;
19879 }
19880 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19881         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19882         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19883         return ret_conv;
19884 }
19885
19886 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19887         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19888         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19889         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19890         return (uint32_t)ret_conv;
19891 }
19892
19893 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19894         LDKReplyShortChannelIdsEnd o_conv;
19895         o_conv.inner = (void*)(o & (~1));
19896         o_conv.is_owned = (o & 1) || (o == 0);
19897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19898         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19899         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19900         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19901         return (uint32_t)ret_conv;
19902 }
19903
19904 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19905         LDKDecodeError e_conv;
19906         e_conv.inner = (void*)(e & (~1));
19907         e_conv.is_owned = (e & 1) || (e == 0);
19908         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19909         e_conv = DecodeError_clone(&e_conv);
19910         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19911         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19912         return (uint32_t)ret_conv;
19913 }
19914
19915 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19916         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19917         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19918         return ret_conv;
19919 }
19920
19921 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19922         if ((_res & 1) != 0) return;
19923         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19924         CHECK_ACCESS(_res_ptr);
19925         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19926         FREE((void*)_res);
19927         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19928 }
19929
19930 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19931         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19932         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19933         return (uint32_t)ret_conv;
19934 }
19935 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19936         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19937         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19938         return ret_conv;
19939 }
19940
19941 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19942         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19943         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19944         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19945         return (uint32_t)ret_conv;
19946 }
19947
19948 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19949         LDKQueryChannelRange o_conv;
19950         o_conv.inner = (void*)(o & (~1));
19951         o_conv.is_owned = (o & 1) || (o == 0);
19952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19953         o_conv = QueryChannelRange_clone(&o_conv);
19954         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19955         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19956         return (uint32_t)ret_conv;
19957 }
19958
19959 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19960         LDKDecodeError e_conv;
19961         e_conv.inner = (void*)(e & (~1));
19962         e_conv.is_owned = (e & 1) || (e == 0);
19963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19964         e_conv = DecodeError_clone(&e_conv);
19965         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19966         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19967         return (uint32_t)ret_conv;
19968 }
19969
19970 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19971         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19972         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19973         return ret_conv;
19974 }
19975
19976 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19977         if ((_res & 1) != 0) return;
19978         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19979         CHECK_ACCESS(_res_ptr);
19980         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19981         FREE((void*)_res);
19982         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19983 }
19984
19985 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19986         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19987         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19988         return (uint32_t)ret_conv;
19989 }
19990 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19991         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19992         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19993         return ret_conv;
19994 }
19995
19996 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19997         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19998         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19999         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20000         return (uint32_t)ret_conv;
20001 }
20002
20003 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
20004         LDKReplyChannelRange o_conv;
20005         o_conv.inner = (void*)(o & (~1));
20006         o_conv.is_owned = (o & 1) || (o == 0);
20007         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20008         o_conv = ReplyChannelRange_clone(&o_conv);
20009         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20010         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20011         return (uint32_t)ret_conv;
20012 }
20013
20014 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
20015         LDKDecodeError e_conv;
20016         e_conv.inner = (void*)(e & (~1));
20017         e_conv.is_owned = (e & 1) || (e == 0);
20018         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20019         e_conv = DecodeError_clone(&e_conv);
20020         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20021         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20022         return (uint32_t)ret_conv;
20023 }
20024
20025 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20026         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
20027         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20028         return ret_conv;
20029 }
20030
20031 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
20032         if ((_res & 1) != 0) return;
20033         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20034         CHECK_ACCESS(_res_ptr);
20035         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20036         FREE((void*)_res);
20037         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20038 }
20039
20040 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20041         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20042         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20043         return (uint32_t)ret_conv;
20044 }
20045 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20046         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
20047         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20048         return ret_conv;
20049 }
20050
20051 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20052         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
20053         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20054         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20055         return (uint32_t)ret_conv;
20056 }
20057
20058 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
20059         LDKGossipTimestampFilter o_conv;
20060         o_conv.inner = (void*)(o & (~1));
20061         o_conv.is_owned = (o & 1) || (o == 0);
20062         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20063         o_conv = GossipTimestampFilter_clone(&o_conv);
20064         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20065         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20066         return (uint32_t)ret_conv;
20067 }
20068
20069 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
20070         LDKDecodeError e_conv;
20071         e_conv.inner = (void*)(e & (~1));
20072         e_conv.is_owned = (e & 1) || (e == 0);
20073         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20074         e_conv = DecodeError_clone(&e_conv);
20075         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20076         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20077         return (uint32_t)ret_conv;
20078 }
20079
20080 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
20081         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
20082         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20083         return ret_conv;
20084 }
20085
20086 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
20087         if ((_res & 1) != 0) return;
20088         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20089         CHECK_ACCESS(_res_ptr);
20090         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20091         FREE((void*)_res);
20092         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20093 }
20094
20095 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20096         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20097         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20098         return (uint32_t)ret_conv;
20099 }
20100 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
20101         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
20102         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20103         return ret_conv;
20104 }
20105
20106 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
20107         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
20108         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20109         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20110         return (uint32_t)ret_conv;
20111 }
20112
20113 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
20114         LDKInvoice o_conv;
20115         o_conv.inner = (void*)(o & (~1));
20116         o_conv.is_owned = (o & 1) || (o == 0);
20117         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20118         o_conv = Invoice_clone(&o_conv);
20119         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20120         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20121         return (uint32_t)ret_conv;
20122 }
20123
20124 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
20125         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20126         CHECK_ACCESS(e_ptr);
20127         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20128         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
20129         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20130         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20131         return (uint32_t)ret_conv;
20132 }
20133
20134 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
20135         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
20136         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20137         return ret_conv;
20138 }
20139
20140 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
20141         if ((_res & 1) != 0) return;
20142         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20143         CHECK_ACCESS(_res_ptr);
20144         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20145         FREE((void*)_res);
20146         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20147 }
20148
20149 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20150         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20151         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20152         return (uint32_t)ret_conv;
20153 }
20154 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
20155         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
20156         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20157         return ret_conv;
20158 }
20159
20160 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
20161         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
20162         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20163         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20164         return (uint32_t)ret_conv;
20165 }
20166
20167 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
20168         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20169         CHECK_ACCESS(o_ptr);
20170         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20171         if (o_conv.free == LDKFilter_JCalls_free) {
20172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20173                 LDKFilter_JCalls_cloned(&o_conv);
20174         }
20175         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20176         *ret_copy = COption_FilterZ_some(o_conv);
20177         uint32_t ret_ref = (uintptr_t)ret_copy;
20178         return ret_ref;
20179 }
20180
20181 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20182         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20183         *ret_copy = COption_FilterZ_none();
20184         uint32_t ret_ref = (uintptr_t)ret_copy;
20185         return ret_ref;
20186 }
20187
20188 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
20189         if ((_res & 1) != 0) return;
20190         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20191         CHECK_ACCESS(_res_ptr);
20192         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20193         FREE((void*)_res);
20194         COption_FilterZ_free(_res_conv);
20195 }
20196
20197 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
20198         LDKLockedChannelMonitor o_conv;
20199         o_conv.inner = (void*)(o & (~1));
20200         o_conv.is_owned = (o & 1) || (o == 0);
20201         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20202         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20203         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20204         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20205         return (uint32_t)ret_conv;
20206 }
20207
20208 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20209         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20210         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20211         return (uint32_t)ret_conv;
20212 }
20213
20214 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
20215         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
20216         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20217         return ret_conv;
20218 }
20219
20220 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
20221         if ((_res & 1) != 0) return;
20222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20223         CHECK_ACCESS(_res_ptr);
20224         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20225         FREE((void*)_res);
20226         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20227 }
20228
20229 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
20230         LDKCVec_OutPointZ _res_constr;
20231         _res_constr.datalen = _res->arr_len;
20232         if (_res_constr.datalen > 0)
20233                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20234         else
20235                 _res_constr.data = NULL;
20236         uint32_t* _res_vals = _res->elems;
20237         for (size_t k = 0; k < _res_constr.datalen; k++) {
20238                 uint32_t _res_conv_10 = _res_vals[k];
20239                 LDKOutPoint _res_conv_10_conv;
20240                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
20241                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
20242                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20243                 _res_constr.data[k] = _res_conv_10_conv;
20244         }
20245         FREE(_res);
20246         CVec_OutPointZ_free(_res_constr);
20247 }
20248
20249 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
20250         if ((this_ptr & 1) != 0) return;
20251         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20252         CHECK_ACCESS(this_ptr_ptr);
20253         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20254         FREE((void*)this_ptr);
20255         PaymentPurpose_free(this_ptr_conv);
20256 }
20257
20258 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20259         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20260         *ret_copy = PaymentPurpose_clone(arg);
20261 uint32_t ret_ref = (uintptr_t)ret_copy;
20262         return ret_ref;
20263 }
20264 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
20265         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
20266         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20267         return ret_conv;
20268 }
20269
20270 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
20271         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
20272         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20273         *ret_copy = PaymentPurpose_clone(orig_conv);
20274         uint32_t ret_ref = (uintptr_t)ret_copy;
20275         return ret_ref;
20276 }
20277
20278 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20279         LDKThirtyTwoBytes payment_preimage_ref;
20280         CHECK(payment_preimage->arr_len == 32);
20281         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20282         LDKThirtyTwoBytes payment_secret_ref;
20283         CHECK(payment_secret->arr_len == 32);
20284         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20285         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20286         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20287         uint32_t ret_ref = (uintptr_t)ret_copy;
20288         return ret_ref;
20289 }
20290
20291 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20292         LDKThirtyTwoBytes a_ref;
20293         CHECK(a->arr_len == 32);
20294         memcpy(a_ref.data, a->elems, 32); FREE(a);
20295         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20296         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20297         uint32_t ret_ref = (uintptr_t)ret_copy;
20298         return ret_ref;
20299 }
20300
20301 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
20302         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
20303         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20304         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20305         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20306         CVec_u8Z_free(ret_var);
20307         return ret_arr;
20308 }
20309
20310 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20311         LDKu8slice ser_ref;
20312         ser_ref.datalen = ser->arr_len;
20313         ser_ref.data = ser->elems;
20314         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20315         *ret_conv = PaymentPurpose_read(ser_ref);
20316         FREE(ser);
20317         return (uint32_t)ret_conv;
20318 }
20319
20320 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
20321         if ((this_ptr & 1) != 0) return;
20322         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20323         CHECK_ACCESS(this_ptr_ptr);
20324         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20325         FREE((void*)this_ptr);
20326         ClosureReason_free(this_ptr_conv);
20327 }
20328
20329 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20330         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20331         *ret_copy = ClosureReason_clone(arg);
20332 uint32_t ret_ref = (uintptr_t)ret_copy;
20333         return ret_ref;
20334 }
20335 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20336         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20337         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20338         return ret_conv;
20339 }
20340
20341 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20342         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20343         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20344         *ret_copy = ClosureReason_clone(orig_conv);
20345         uint32_t ret_ref = (uintptr_t)ret_copy;
20346         return ret_ref;
20347 }
20348
20349 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20350         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20351         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20352         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20353         uint32_t ret_ref = (uintptr_t)ret_copy;
20354         return ret_ref;
20355 }
20356
20357 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20358         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20359         *ret_copy = ClosureReason_holder_force_closed();
20360         uint32_t ret_ref = (uintptr_t)ret_copy;
20361         return ret_ref;
20362 }
20363
20364 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20365         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20366         *ret_copy = ClosureReason_cooperative_closure();
20367         uint32_t ret_ref = (uintptr_t)ret_copy;
20368         return ret_ref;
20369 }
20370
20371 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20372         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20373         *ret_copy = ClosureReason_commitment_tx_confirmed();
20374         uint32_t ret_ref = (uintptr_t)ret_copy;
20375         return ret_ref;
20376 }
20377
20378 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20379         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20380         *ret_copy = ClosureReason_funding_timed_out();
20381         uint32_t ret_ref = (uintptr_t)ret_copy;
20382         return ret_ref;
20383 }
20384
20385 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20386         LDKStr err_conv = str_ref_to_owned_c(err);
20387         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20388         *ret_copy = ClosureReason_processing_error(err_conv);
20389         uint32_t ret_ref = (uintptr_t)ret_copy;
20390         return ret_ref;
20391 }
20392
20393 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20394         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20395         *ret_copy = ClosureReason_disconnected_peer();
20396         uint32_t ret_ref = (uintptr_t)ret_copy;
20397         return ret_ref;
20398 }
20399
20400 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20401         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20402         *ret_copy = ClosureReason_outdated_channel_manager();
20403         uint32_t ret_ref = (uintptr_t)ret_copy;
20404         return ret_ref;
20405 }
20406
20407 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20408         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20409         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20410         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20411         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20412         CVec_u8Z_free(ret_var);
20413         return ret_arr;
20414 }
20415
20416 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20417         LDKu8slice ser_ref;
20418         ser_ref.datalen = ser->arr_len;
20419         ser_ref.data = ser->elems;
20420         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20421         *ret_conv = ClosureReason_read(ser_ref);
20422         FREE(ser);
20423         return (uint32_t)ret_conv;
20424 }
20425
20426 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20427         if ((this_ptr & 1) != 0) return;
20428         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20429         CHECK_ACCESS(this_ptr_ptr);
20430         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20431         FREE((void*)this_ptr);
20432         Event_free(this_ptr_conv);
20433 }
20434
20435 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20436         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20437         *ret_copy = Event_clone(arg);
20438 uint32_t ret_ref = (uintptr_t)ret_copy;
20439         return ret_ref;
20440 }
20441 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20442         LDKEvent* arg_conv = (LDKEvent*)arg;
20443         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20444         return ret_conv;
20445 }
20446
20447 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20448         LDKEvent* orig_conv = (LDKEvent*)orig;
20449         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20450         *ret_copy = Event_clone(orig_conv);
20451         uint32_t ret_ref = (uintptr_t)ret_copy;
20452         return ret_ref;
20453 }
20454
20455 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) {
20456         LDKThirtyTwoBytes temporary_channel_id_ref;
20457         CHECK(temporary_channel_id->arr_len == 32);
20458         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20459         LDKPublicKey counterparty_node_id_ref;
20460         CHECK(counterparty_node_id->arr_len == 33);
20461         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20462         LDKCVec_u8Z output_script_ref;
20463         output_script_ref.datalen = output_script->arr_len;
20464         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20465         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20466         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20467         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20468         uint32_t ret_ref = (uintptr_t)ret_copy;
20469         return ret_ref;
20470 }
20471
20472 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20473         LDKThirtyTwoBytes payment_hash_ref;
20474         CHECK(payment_hash->arr_len == 32);
20475         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20476         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20477         CHECK_ACCESS(purpose_ptr);
20478         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20479         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20480         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20481         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20482         uint32_t ret_ref = (uintptr_t)ret_copy;
20483         return ret_ref;
20484 }
20485
20486 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20487         LDKThirtyTwoBytes payment_hash_ref;
20488         CHECK(payment_hash->arr_len == 32);
20489         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20490         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20491         CHECK_ACCESS(purpose_ptr);
20492         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20493         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20494         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20495         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20496         uint32_t ret_ref = (uintptr_t)ret_copy;
20497         return ret_ref;
20498 }
20499
20500 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) {
20501         LDKThirtyTwoBytes payment_id_ref;
20502         CHECK(payment_id->arr_len == 32);
20503         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20504         LDKThirtyTwoBytes payment_preimage_ref;
20505         CHECK(payment_preimage->arr_len == 32);
20506         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20507         LDKThirtyTwoBytes payment_hash_ref;
20508         CHECK(payment_hash->arr_len == 32);
20509         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20510         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20511         CHECK_ACCESS(fee_paid_msat_ptr);
20512         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20513         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20514         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20515         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20516         uint32_t ret_ref = (uintptr_t)ret_copy;
20517         return ret_ref;
20518 }
20519
20520 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20521         LDKThirtyTwoBytes payment_id_ref;
20522         CHECK(payment_id->arr_len == 32);
20523         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20524         LDKThirtyTwoBytes payment_hash_ref;
20525         CHECK(payment_hash->arr_len == 32);
20526         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20527         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20528         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
20529         uint32_t ret_ref = (uintptr_t)ret_copy;
20530         return ret_ref;
20531 }
20532
20533 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) {
20534         LDKThirtyTwoBytes payment_id_ref;
20535         CHECK(payment_id->arr_len == 32);
20536         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20537         LDKThirtyTwoBytes payment_hash_ref;
20538         CHECK(payment_hash->arr_len == 32);
20539         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20540         LDKCVec_RouteHopZ path_constr;
20541         path_constr.datalen = path->arr_len;
20542         if (path_constr.datalen > 0)
20543                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20544         else
20545                 path_constr.data = NULL;
20546         uint32_t* path_vals = path->elems;
20547         for (size_t k = 0; k < path_constr.datalen; k++) {
20548                 uint32_t path_conv_10 = path_vals[k];
20549                 LDKRouteHop path_conv_10_conv;
20550                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20551                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20552                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20553                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20554                 path_constr.data[k] = path_conv_10_conv;
20555         }
20556         FREE(path);
20557         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20558         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
20559         uint32_t ret_ref = (uintptr_t)ret_copy;
20560         return ret_ref;
20561 }
20562
20563 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) {
20564         LDKThirtyTwoBytes payment_id_ref;
20565         CHECK(payment_id->arr_len == 32);
20566         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20567         LDKThirtyTwoBytes payment_hash_ref;
20568         CHECK(payment_hash->arr_len == 32);
20569         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20570         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
20571         CHECK_ACCESS(network_update_ptr);
20572         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
20573         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
20574         LDKCVec_RouteHopZ path_constr;
20575         path_constr.datalen = path->arr_len;
20576         if (path_constr.datalen > 0)
20577                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20578         else
20579                 path_constr.data = NULL;
20580         uint32_t* path_vals = path->elems;
20581         for (size_t k = 0; k < path_constr.datalen; k++) {
20582                 uint32_t path_conv_10 = path_vals[k];
20583                 LDKRouteHop path_conv_10_conv;
20584                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20585                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20586                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20587                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20588                 path_constr.data[k] = path_conv_10_conv;
20589         }
20590         FREE(path);
20591         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
20592         CHECK_ACCESS(short_channel_id_ptr);
20593         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
20594         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
20595         LDKRouteParameters retry_conv;
20596         retry_conv.inner = (void*)(retry & (~1));
20597         retry_conv.is_owned = (retry & 1) || (retry == 0);
20598         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
20599         retry_conv = RouteParameters_clone(&retry_conv);
20600         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20601         *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);
20602         uint32_t ret_ref = (uintptr_t)ret_copy;
20603         return ret_ref;
20604 }
20605
20606 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
20607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20608         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
20609         uint32_t ret_ref = (uintptr_t)ret_copy;
20610         return ret_ref;
20611 }
20612
20613 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
20614         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
20615         outputs_constr.datalen = outputs->arr_len;
20616         if (outputs_constr.datalen > 0)
20617                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20618         else
20619                 outputs_constr.data = NULL;
20620         uint32_t* outputs_vals = outputs->elems;
20621         for (size_t b = 0; b < outputs_constr.datalen; b++) {
20622                 uint32_t outputs_conv_27 = outputs_vals[b];
20623                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
20624                 CHECK_ACCESS(outputs_conv_27_ptr);
20625                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
20626                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
20627                 outputs_constr.data[b] = outputs_conv_27_conv;
20628         }
20629         FREE(outputs);
20630         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20631         *ret_copy = Event_spendable_outputs(outputs_constr);
20632         uint32_t ret_ref = (uintptr_t)ret_copy;
20633         return ret_ref;
20634 }
20635
20636 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) {
20637         LDKThirtyTwoBytes prev_channel_id_ref;
20638         CHECK(prev_channel_id->arr_len == 32);
20639         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
20640         LDKThirtyTwoBytes next_channel_id_ref;
20641         CHECK(next_channel_id->arr_len == 32);
20642         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
20643         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
20644         CHECK_ACCESS(fee_earned_msat_ptr);
20645         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
20646         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
20647         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20648         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
20649         uint32_t ret_ref = (uintptr_t)ret_copy;
20650         return ret_ref;
20651 }
20652
20653 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) {
20654         LDKThirtyTwoBytes channel_id_ref;
20655         CHECK(channel_id->arr_len == 32);
20656         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20657         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
20658         CHECK_ACCESS(reason_ptr);
20659         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
20660         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
20661         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20662         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
20663         uint32_t ret_ref = (uintptr_t)ret_copy;
20664         return ret_ref;
20665 }
20666
20667 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
20668         LDKThirtyTwoBytes channel_id_ref;
20669         CHECK(channel_id->arr_len == 32);
20670         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20671         LDKTransaction transaction_ref;
20672         transaction_ref.datalen = transaction->arr_len;
20673         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
20674         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
20675         transaction_ref.data_is_owned = true;
20676         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20677         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
20678         uint32_t ret_ref = (uintptr_t)ret_copy;
20679         return ret_ref;
20680 }
20681
20682 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) {
20683         LDKThirtyTwoBytes temporary_channel_id_ref;
20684         CHECK(temporary_channel_id->arr_len == 32);
20685         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20686         LDKPublicKey counterparty_node_id_ref;
20687         CHECK(counterparty_node_id->arr_len == 33);
20688         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20689         LDKChannelTypeFeatures channel_type_conv;
20690         channel_type_conv.inner = (void*)(channel_type & (~1));
20691         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
20692         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
20693         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
20694         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20695         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
20696         uint32_t ret_ref = (uintptr_t)ret_copy;
20697         return ret_ref;
20698 }
20699
20700 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
20701         LDKEvent* obj_conv = (LDKEvent*)obj;
20702         LDKCVec_u8Z ret_var = Event_write(obj_conv);
20703         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20704         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20705         CVec_u8Z_free(ret_var);
20706         return ret_arr;
20707 }
20708
20709 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
20710         LDKu8slice ser_ref;
20711         ser_ref.datalen = ser->arr_len;
20712         ser_ref.data = ser->elems;
20713         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
20714         *ret_conv = Event_read(ser_ref);
20715         FREE(ser);
20716         return (uint32_t)ret_conv;
20717 }
20718
20719 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
20720         if ((this_ptr & 1) != 0) return;
20721         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20722         CHECK_ACCESS(this_ptr_ptr);
20723         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
20724         FREE((void*)this_ptr);
20725         MessageSendEvent_free(this_ptr_conv);
20726 }
20727
20728 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
20729         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20730         *ret_copy = MessageSendEvent_clone(arg);
20731 uint32_t ret_ref = (uintptr_t)ret_copy;
20732         return ret_ref;
20733 }
20734 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
20735         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
20736         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
20737         return ret_conv;
20738 }
20739
20740 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
20741         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
20742         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20743         *ret_copy = MessageSendEvent_clone(orig_conv);
20744         uint32_t ret_ref = (uintptr_t)ret_copy;
20745         return ret_ref;
20746 }
20747
20748 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
20749         LDKPublicKey node_id_ref;
20750         CHECK(node_id->arr_len == 33);
20751         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20752         LDKAcceptChannel msg_conv;
20753         msg_conv.inner = (void*)(msg & (~1));
20754         msg_conv.is_owned = (msg & 1) || (msg == 0);
20755         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20756         msg_conv = AcceptChannel_clone(&msg_conv);
20757         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20758         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
20759         uint32_t ret_ref = (uintptr_t)ret_copy;
20760         return ret_ref;
20761 }
20762
20763 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
20764         LDKPublicKey node_id_ref;
20765         CHECK(node_id->arr_len == 33);
20766         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20767         LDKOpenChannel msg_conv;
20768         msg_conv.inner = (void*)(msg & (~1));
20769         msg_conv.is_owned = (msg & 1) || (msg == 0);
20770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20771         msg_conv = OpenChannel_clone(&msg_conv);
20772         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20773         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
20774         uint32_t ret_ref = (uintptr_t)ret_copy;
20775         return ret_ref;
20776 }
20777
20778 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
20779         LDKPublicKey node_id_ref;
20780         CHECK(node_id->arr_len == 33);
20781         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20782         LDKFundingCreated msg_conv;
20783         msg_conv.inner = (void*)(msg & (~1));
20784         msg_conv.is_owned = (msg & 1) || (msg == 0);
20785         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20786         msg_conv = FundingCreated_clone(&msg_conv);
20787         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20788         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
20789         uint32_t ret_ref = (uintptr_t)ret_copy;
20790         return ret_ref;
20791 }
20792
20793 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
20794         LDKPublicKey node_id_ref;
20795         CHECK(node_id->arr_len == 33);
20796         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20797         LDKFundingSigned msg_conv;
20798         msg_conv.inner = (void*)(msg & (~1));
20799         msg_conv.is_owned = (msg & 1) || (msg == 0);
20800         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20801         msg_conv = FundingSigned_clone(&msg_conv);
20802         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20803         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
20804         uint32_t ret_ref = (uintptr_t)ret_copy;
20805         return ret_ref;
20806 }
20807
20808 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
20809         LDKPublicKey node_id_ref;
20810         CHECK(node_id->arr_len == 33);
20811         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20812         LDKChannelReady msg_conv;
20813         msg_conv.inner = (void*)(msg & (~1));
20814         msg_conv.is_owned = (msg & 1) || (msg == 0);
20815         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20816         msg_conv = ChannelReady_clone(&msg_conv);
20817         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20818         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
20819         uint32_t ret_ref = (uintptr_t)ret_copy;
20820         return ret_ref;
20821 }
20822
20823 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
20824         LDKPublicKey node_id_ref;
20825         CHECK(node_id->arr_len == 33);
20826         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20827         LDKAnnouncementSignatures msg_conv;
20828         msg_conv.inner = (void*)(msg & (~1));
20829         msg_conv.is_owned = (msg & 1) || (msg == 0);
20830         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20831         msg_conv = AnnouncementSignatures_clone(&msg_conv);
20832         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20833         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
20834         uint32_t ret_ref = (uintptr_t)ret_copy;
20835         return ret_ref;
20836 }
20837
20838 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
20839         LDKPublicKey node_id_ref;
20840         CHECK(node_id->arr_len == 33);
20841         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20842         LDKCommitmentUpdate updates_conv;
20843         updates_conv.inner = (void*)(updates & (~1));
20844         updates_conv.is_owned = (updates & 1) || (updates == 0);
20845         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
20846         updates_conv = CommitmentUpdate_clone(&updates_conv);
20847         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20848         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
20849         uint32_t ret_ref = (uintptr_t)ret_copy;
20850         return ret_ref;
20851 }
20852
20853 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
20854         LDKPublicKey node_id_ref;
20855         CHECK(node_id->arr_len == 33);
20856         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20857         LDKRevokeAndACK msg_conv;
20858         msg_conv.inner = (void*)(msg & (~1));
20859         msg_conv.is_owned = (msg & 1) || (msg == 0);
20860         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20861         msg_conv = RevokeAndACK_clone(&msg_conv);
20862         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20863         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20864         uint32_t ret_ref = (uintptr_t)ret_copy;
20865         return ret_ref;
20866 }
20867
20868 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
20869         LDKPublicKey node_id_ref;
20870         CHECK(node_id->arr_len == 33);
20871         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20872         LDKClosingSigned msg_conv;
20873         msg_conv.inner = (void*)(msg & (~1));
20874         msg_conv.is_owned = (msg & 1) || (msg == 0);
20875         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20876         msg_conv = ClosingSigned_clone(&msg_conv);
20877         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20878         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20879         uint32_t ret_ref = (uintptr_t)ret_copy;
20880         return ret_ref;
20881 }
20882
20883 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
20884         LDKPublicKey node_id_ref;
20885         CHECK(node_id->arr_len == 33);
20886         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20887         LDKShutdown msg_conv;
20888         msg_conv.inner = (void*)(msg & (~1));
20889         msg_conv.is_owned = (msg & 1) || (msg == 0);
20890         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20891         msg_conv = Shutdown_clone(&msg_conv);
20892         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20893         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20894         uint32_t ret_ref = (uintptr_t)ret_copy;
20895         return ret_ref;
20896 }
20897
20898 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
20899         LDKPublicKey node_id_ref;
20900         CHECK(node_id->arr_len == 33);
20901         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20902         LDKChannelReestablish msg_conv;
20903         msg_conv.inner = (void*)(msg & (~1));
20904         msg_conv.is_owned = (msg & 1) || (msg == 0);
20905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20906         msg_conv = ChannelReestablish_clone(&msg_conv);
20907         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20908         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20909         uint32_t ret_ref = (uintptr_t)ret_copy;
20910         return ret_ref;
20911 }
20912
20913 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
20914         LDKChannelAnnouncement msg_conv;
20915         msg_conv.inner = (void*)(msg & (~1));
20916         msg_conv.is_owned = (msg & 1) || (msg == 0);
20917         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20918         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20919         LDKChannelUpdate update_msg_conv;
20920         update_msg_conv.inner = (void*)(update_msg & (~1));
20921         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20922         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20923         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20924         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20925         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20926         uint32_t ret_ref = (uintptr_t)ret_copy;
20927         return ret_ref;
20928 }
20929
20930 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20931         LDKNodeAnnouncement msg_conv;
20932         msg_conv.inner = (void*)(msg & (~1));
20933         msg_conv.is_owned = (msg & 1) || (msg == 0);
20934         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20935         msg_conv = NodeAnnouncement_clone(&msg_conv);
20936         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20937         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20938         uint32_t ret_ref = (uintptr_t)ret_copy;
20939         return ret_ref;
20940 }
20941
20942 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20943         LDKChannelUpdate msg_conv;
20944         msg_conv.inner = (void*)(msg & (~1));
20945         msg_conv.is_owned = (msg & 1) || (msg == 0);
20946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20947         msg_conv = ChannelUpdate_clone(&msg_conv);
20948         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20949         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20950         uint32_t ret_ref = (uintptr_t)ret_copy;
20951         return ret_ref;
20952 }
20953
20954 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20955         LDKPublicKey node_id_ref;
20956         CHECK(node_id->arr_len == 33);
20957         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20958         LDKChannelUpdate msg_conv;
20959         msg_conv.inner = (void*)(msg & (~1));
20960         msg_conv.is_owned = (msg & 1) || (msg == 0);
20961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20962         msg_conv = ChannelUpdate_clone(&msg_conv);
20963         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20964         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20965         uint32_t ret_ref = (uintptr_t)ret_copy;
20966         return ret_ref;
20967 }
20968
20969 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20970         LDKPublicKey node_id_ref;
20971         CHECK(node_id->arr_len == 33);
20972         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20973         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20974         CHECK_ACCESS(action_ptr);
20975         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20976         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20977         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20978         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20979         uint32_t ret_ref = (uintptr_t)ret_copy;
20980         return ret_ref;
20981 }
20982
20983 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20984         LDKPublicKey node_id_ref;
20985         CHECK(node_id->arr_len == 33);
20986         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20987         LDKQueryChannelRange msg_conv;
20988         msg_conv.inner = (void*)(msg & (~1));
20989         msg_conv.is_owned = (msg & 1) || (msg == 0);
20990         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20991         msg_conv = QueryChannelRange_clone(&msg_conv);
20992         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20993         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20994         uint32_t ret_ref = (uintptr_t)ret_copy;
20995         return ret_ref;
20996 }
20997
20998 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20999         LDKPublicKey node_id_ref;
21000         CHECK(node_id->arr_len == 33);
21001         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21002         LDKQueryShortChannelIds msg_conv;
21003         msg_conv.inner = (void*)(msg & (~1));
21004         msg_conv.is_owned = (msg & 1) || (msg == 0);
21005         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21006         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21007         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21008         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21009         uint32_t ret_ref = (uintptr_t)ret_copy;
21010         return ret_ref;
21011 }
21012
21013 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
21014         LDKPublicKey node_id_ref;
21015         CHECK(node_id->arr_len == 33);
21016         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21017         LDKReplyChannelRange msg_conv;
21018         msg_conv.inner = (void*)(msg & (~1));
21019         msg_conv.is_owned = (msg & 1) || (msg == 0);
21020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21021         msg_conv = ReplyChannelRange_clone(&msg_conv);
21022         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21023         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21024         uint32_t ret_ref = (uintptr_t)ret_copy;
21025         return ret_ref;
21026 }
21027
21028 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
21029         LDKPublicKey node_id_ref;
21030         CHECK(node_id->arr_len == 33);
21031         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21032         LDKGossipTimestampFilter msg_conv;
21033         msg_conv.inner = (void*)(msg & (~1));
21034         msg_conv.is_owned = (msg & 1) || (msg == 0);
21035         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21036         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21037         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21038         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21039         uint32_t ret_ref = (uintptr_t)ret_copy;
21040         return ret_ref;
21041 }
21042
21043 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
21044         if ((this_ptr & 1) != 0) return;
21045         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21046         CHECK_ACCESS(this_ptr_ptr);
21047         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21048         FREE((void*)this_ptr);
21049         MessageSendEventsProvider_free(this_ptr_conv);
21050 }
21051
21052 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
21053         if ((this_ptr & 1) != 0) return;
21054         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21055         CHECK_ACCESS(this_ptr_ptr);
21056         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21057         FREE((void*)this_ptr);
21058         EventsProvider_free(this_ptr_conv);
21059 }
21060
21061 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
21062         if ((this_ptr & 1) != 0) return;
21063         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21064         CHECK_ACCESS(this_ptr_ptr);
21065         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21066         FREE((void*)this_ptr);
21067         EventHandler_free(this_ptr_conv);
21068 }
21069
21070 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
21071         if ((this_ptr & 1) != 0) return;
21072         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21073         CHECK_ACCESS(this_ptr_ptr);
21074         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21075         FREE((void*)this_ptr);
21076         APIError_free(this_ptr_conv);
21077 }
21078
21079 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21080         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21081         *ret_copy = APIError_clone(arg);
21082 uint32_t ret_ref = (uintptr_t)ret_copy;
21083         return ret_ref;
21084 }
21085 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
21086         LDKAPIError* arg_conv = (LDKAPIError*)arg;
21087         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
21088         return ret_conv;
21089 }
21090
21091 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
21092         LDKAPIError* orig_conv = (LDKAPIError*)orig;
21093         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21094         *ret_copy = APIError_clone(orig_conv);
21095         uint32_t ret_ref = (uintptr_t)ret_copy;
21096         return ret_ref;
21097 }
21098
21099 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21100         LDKStr err_conv = str_ref_to_owned_c(err);
21101         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21102         *ret_copy = APIError_apimisuse_error(err_conv);
21103         uint32_t ret_ref = (uintptr_t)ret_copy;
21104         return ret_ref;
21105 }
21106
21107 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21108         LDKStr err_conv = str_ref_to_owned_c(err);
21109         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21110         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21111         uint32_t ret_ref = (uintptr_t)ret_copy;
21112         return ret_ref;
21113 }
21114
21115 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21116         LDKStr err_conv = str_ref_to_owned_c(err);
21117         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21118         *ret_copy = APIError_route_error(err_conv);
21119         uint32_t ret_ref = (uintptr_t)ret_copy;
21120         return ret_ref;
21121 }
21122
21123 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21124         LDKStr err_conv = str_ref_to_owned_c(err);
21125         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21126         *ret_copy = APIError_channel_unavailable(err_conv);
21127         uint32_t ret_ref = (uintptr_t)ret_copy;
21128         return ret_ref;
21129 }
21130
21131 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21132         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21133         *ret_copy = APIError_monitor_update_failed();
21134         uint32_t ret_ref = (uintptr_t)ret_copy;
21135         return ret_ref;
21136 }
21137
21138 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
21139         LDKShutdownScript script_conv;
21140         script_conv.inner = (void*)(script & (~1));
21141         script_conv.is_owned = (script & 1) || (script == 0);
21142         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21143         script_conv = ShutdownScript_clone(&script_conv);
21144         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21145         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21146         uint32_t ret_ref = (uintptr_t)ret_copy;
21147         return ret_ref;
21148 }
21149
21150 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
21151         LDKBigSize this_obj_conv;
21152         this_obj_conv.inner = (void*)(this_obj & (~1));
21153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21155         BigSize_free(this_obj_conv);
21156 }
21157
21158 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
21159         LDKBigSize this_ptr_conv;
21160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21161         this_ptr_conv.is_owned = false;
21162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21163         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21164         return ret_conv;
21165 }
21166
21167 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
21168         LDKBigSize this_ptr_conv;
21169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21170         this_ptr_conv.is_owned = false;
21171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21172         BigSize_set_a(&this_ptr_conv, val);
21173 }
21174
21175 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21176         LDKBigSize ret_var = BigSize_new(a_arg);
21177         uint32_t ret_ref = 0;
21178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21181         ret_ref = (uintptr_t)ret_var.inner;
21182         if (ret_var.is_owned) {
21183                 ret_ref |= 1;
21184         }
21185         return ret_ref;
21186 }
21187
21188 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21189         LDKu8slice msg_ref;
21190         msg_ref.datalen = msg->arr_len;
21191         msg_ref.data = msg->elems;
21192         unsigned char sk_arr[32];
21193         CHECK(sk->arr_len == 32);
21194         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21195         unsigned char (*sk_ref)[32] = &sk_arr;
21196         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21197         *ret_conv = sign(msg_ref, sk_ref);
21198         FREE(msg);
21199         return (uint32_t)ret_conv;
21200 }
21201
21202 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21203         LDKu8slice msg_ref;
21204         msg_ref.datalen = msg->arr_len;
21205         msg_ref.data = msg->elems;
21206         LDKStr sig_conv = str_ref_to_owned_c(sig);
21207         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21208         *ret_conv = recover_pk(msg_ref, sig_conv);
21209         FREE(msg);
21210         return (uint32_t)ret_conv;
21211 }
21212
21213 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21214         LDKu8slice msg_ref;
21215         msg_ref.datalen = msg->arr_len;
21216         msg_ref.data = msg->elems;
21217         LDKStr sig_conv = str_ref_to_owned_c(sig);
21218         LDKPublicKey pk_ref;
21219         CHECK(pk->arr_len == 33);
21220         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21221         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21222         FREE(msg);
21223         return ret_conv;
21224 }
21225
21226 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21227         LDKu8slice hrp_bytes_ref;
21228         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21229         hrp_bytes_ref.data = hrp_bytes->elems;
21230         LDKCVec_u5Z data_without_signature_constr;
21231         data_without_signature_constr.datalen = data_without_signature->arr_len;
21232         if (data_without_signature_constr.datalen > 0)
21233                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21234         else
21235                 data_without_signature_constr.data = NULL;
21236         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21237         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21238                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21239                 
21240                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21241         }
21242         FREE(data_without_signature);
21243         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21244         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21245         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21246         CVec_u8Z_free(ret_var);
21247         FREE(hrp_bytes);
21248         return ret_arr;
21249 }
21250
21251 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
21252         if ((this_ptr & 1) != 0) return;
21253         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21254         CHECK_ACCESS(this_ptr_ptr);
21255         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21256         FREE((void*)this_ptr);
21257         Persister_free(this_ptr_conv);
21258 }
21259
21260 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
21261         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
21262         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21263         return ret_conv;
21264 }
21265
21266 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21267         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21268         return ret_conv;
21269 }
21270
21271 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21272         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21273         return ret_conv;
21274 }
21275
21276 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21277         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21278         return ret_conv;
21279 }
21280
21281 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21282         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21283         return ret_conv;
21284 }
21285
21286 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21287         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21288         return ret_conv;
21289 }
21290
21291 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21292         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21293         return ret_conv;
21294 }
21295
21296 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
21297         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
21298         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
21299         jboolean ret_conv = Level_eq(a_conv, b_conv);
21300         return ret_conv;
21301 }
21302
21303 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
21304         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
21305         int64_t ret_conv = Level_hash(o_conv);
21306         return ret_conv;
21307 }
21308
21309 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21310         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21311         return ret_conv;
21312 }
21313
21314 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
21315         LDKRecord this_obj_conv;
21316         this_obj_conv.inner = (void*)(this_obj & (~1));
21317         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21319         Record_free(this_obj_conv);
21320 }
21321
21322 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
21323         LDKRecord this_ptr_conv;
21324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21325         this_ptr_conv.is_owned = false;
21326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21327         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
21328         return ret_conv;
21329 }
21330
21331 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
21332         LDKRecord this_ptr_conv;
21333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21334         this_ptr_conv.is_owned = false;
21335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21336         LDKLevel val_conv = LDKLevel_from_js(val);
21337         Record_set_level(&this_ptr_conv, val_conv);
21338 }
21339
21340 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
21341         LDKRecord this_ptr_conv;
21342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21343         this_ptr_conv.is_owned = false;
21344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21345         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21346         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21347         Str_free(ret_str);
21348         return ret_conv;
21349 }
21350
21351 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21352         LDKRecord this_ptr_conv;
21353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21354         this_ptr_conv.is_owned = false;
21355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21356         LDKStr val_conv = str_ref_to_owned_c(val);
21357         Record_set_args(&this_ptr_conv, val_conv);
21358 }
21359
21360 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21361         LDKRecord this_ptr_conv;
21362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21363         this_ptr_conv.is_owned = false;
21364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21365         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21366         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21367         Str_free(ret_str);
21368         return ret_conv;
21369 }
21370
21371 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21372         LDKRecord this_ptr_conv;
21373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21374         this_ptr_conv.is_owned = false;
21375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21376         LDKStr val_conv = str_ref_to_owned_c(val);
21377         Record_set_module_path(&this_ptr_conv, val_conv);
21378 }
21379
21380 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21381         LDKRecord this_ptr_conv;
21382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21383         this_ptr_conv.is_owned = false;
21384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21385         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21386         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21387         Str_free(ret_str);
21388         return ret_conv;
21389 }
21390
21391 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
21392         LDKRecord this_ptr_conv;
21393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21394         this_ptr_conv.is_owned = false;
21395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21396         LDKStr val_conv = str_ref_to_owned_c(val);
21397         Record_set_file(&this_ptr_conv, val_conv);
21398 }
21399
21400 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
21401         LDKRecord this_ptr_conv;
21402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21403         this_ptr_conv.is_owned = false;
21404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21405         int32_t ret_conv = Record_get_line(&this_ptr_conv);
21406         return ret_conv;
21407 }
21408
21409 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
21410         LDKRecord this_ptr_conv;
21411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21412         this_ptr_conv.is_owned = false;
21413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21414         Record_set_line(&this_ptr_conv, val);
21415 }
21416
21417 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
21418         LDKRecord ret_var = Record_clone(arg);
21419 uint32_t ret_ref = 0;
21420 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21421 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21422 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21423 ret_ref = (uintptr_t)ret_var.inner;
21424 if (ret_var.is_owned) {
21425         ret_ref |= 1;
21426 }
21427         return ret_ref;
21428 }
21429 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
21430         LDKRecord arg_conv;
21431         arg_conv.inner = (void*)(arg & (~1));
21432         arg_conv.is_owned = false;
21433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21434         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
21435         return ret_conv;
21436 }
21437
21438 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
21439         LDKRecord orig_conv;
21440         orig_conv.inner = (void*)(orig & (~1));
21441         orig_conv.is_owned = false;
21442         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21443         LDKRecord ret_var = Record_clone(&orig_conv);
21444         uint32_t ret_ref = 0;
21445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21448         ret_ref = (uintptr_t)ret_var.inner;
21449         if (ret_var.is_owned) {
21450                 ret_ref |= 1;
21451         }
21452         return ret_ref;
21453 }
21454
21455 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
21456         if ((this_ptr & 1) != 0) return;
21457         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21458         CHECK_ACCESS(this_ptr_ptr);
21459         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
21460         FREE((void*)this_ptr);
21461         Logger_free(this_ptr_conv);
21462 }
21463
21464 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
21465         LDKChannelHandshakeConfig this_obj_conv;
21466         this_obj_conv.inner = (void*)(this_obj & (~1));
21467         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21469         ChannelHandshakeConfig_free(this_obj_conv);
21470 }
21471
21472 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
21473         LDKChannelHandshakeConfig this_ptr_conv;
21474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21475         this_ptr_conv.is_owned = false;
21476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21477         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
21478         return ret_conv;
21479 }
21480
21481 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
21482         LDKChannelHandshakeConfig this_ptr_conv;
21483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21484         this_ptr_conv.is_owned = false;
21485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21486         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
21487 }
21488
21489 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
21490         LDKChannelHandshakeConfig this_ptr_conv;
21491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21492         this_ptr_conv.is_owned = false;
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21494         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
21495         return ret_conv;
21496 }
21497
21498 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) {
21499         LDKChannelHandshakeConfig this_ptr_conv;
21500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21501         this_ptr_conv.is_owned = false;
21502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21503         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
21504 }
21505
21506 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
21507         LDKChannelHandshakeConfig this_ptr_conv;
21508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21509         this_ptr_conv.is_owned = false;
21510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21511         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
21512         return ret_conv;
21513 }
21514
21515 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) {
21516         LDKChannelHandshakeConfig this_ptr_conv;
21517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21518         this_ptr_conv.is_owned = false;
21519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21520         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
21521 }
21522
21523 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) {
21524         LDKChannelHandshakeConfig this_ptr_conv;
21525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21526         this_ptr_conv.is_owned = false;
21527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21528         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
21529         return ret_conv;
21530 }
21531
21532 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) {
21533         LDKChannelHandshakeConfig this_ptr_conv;
21534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21535         this_ptr_conv.is_owned = false;
21536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21537         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
21538 }
21539
21540 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
21541         LDKChannelHandshakeConfig this_ptr_conv;
21542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21543         this_ptr_conv.is_owned = false;
21544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21545         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
21546         return ret_conv;
21547 }
21548
21549 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
21550         LDKChannelHandshakeConfig this_ptr_conv;
21551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21552         this_ptr_conv.is_owned = false;
21553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21554         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
21555 }
21556
21557 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint32_t this_ptr) {
21558         LDKChannelHandshakeConfig this_ptr_conv;
21559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21560         this_ptr_conv.is_owned = false;
21561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21562         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
21563         return ret_conv;
21564 }
21565
21566 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
21567         LDKChannelHandshakeConfig this_ptr_conv;
21568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21569         this_ptr_conv.is_owned = false;
21570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21571         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
21572 }
21573
21574 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
21575         LDKChannelHandshakeConfig this_ptr_conv;
21576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21577         this_ptr_conv.is_owned = false;
21578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21579         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
21580         return ret_conv;
21581 }
21582
21583 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
21584         LDKChannelHandshakeConfig this_ptr_conv;
21585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21586         this_ptr_conv.is_owned = false;
21587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21588         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
21589 }
21590
21591 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) {
21592         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);
21593         uint32_t ret_ref = 0;
21594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21597         ret_ref = (uintptr_t)ret_var.inner;
21598         if (ret_var.is_owned) {
21599                 ret_ref |= 1;
21600         }
21601         return ret_ref;
21602 }
21603
21604 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
21605         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
21606 uint32_t ret_ref = 0;
21607 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21608 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21609 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21610 ret_ref = (uintptr_t)ret_var.inner;
21611 if (ret_var.is_owned) {
21612         ret_ref |= 1;
21613 }
21614         return ret_ref;
21615 }
21616 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
21617         LDKChannelHandshakeConfig arg_conv;
21618         arg_conv.inner = (void*)(arg & (~1));
21619         arg_conv.is_owned = false;
21620         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21621         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
21622         return ret_conv;
21623 }
21624
21625 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
21626         LDKChannelHandshakeConfig orig_conv;
21627         orig_conv.inner = (void*)(orig & (~1));
21628         orig_conv.is_owned = false;
21629         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21630         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
21631         uint32_t ret_ref = 0;
21632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21635         ret_ref = (uintptr_t)ret_var.inner;
21636         if (ret_var.is_owned) {
21637                 ret_ref |= 1;
21638         }
21639         return ret_ref;
21640 }
21641
21642 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
21643         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
21644         uint32_t ret_ref = 0;
21645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21648         ret_ref = (uintptr_t)ret_var.inner;
21649         if (ret_var.is_owned) {
21650                 ret_ref |= 1;
21651         }
21652         return ret_ref;
21653 }
21654
21655 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
21656         LDKChannelHandshakeLimits this_obj_conv;
21657         this_obj_conv.inner = (void*)(this_obj & (~1));
21658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21660         ChannelHandshakeLimits_free(this_obj_conv);
21661 }
21662
21663 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
21664         LDKChannelHandshakeLimits this_ptr_conv;
21665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21666         this_ptr_conv.is_owned = false;
21667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21668         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
21669         return ret_conv;
21670 }
21671
21672 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
21673         LDKChannelHandshakeLimits this_ptr_conv;
21674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21675         this_ptr_conv.is_owned = false;
21676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21677         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
21678 }
21679
21680 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
21681         LDKChannelHandshakeLimits this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21685         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
21686         return ret_conv;
21687 }
21688
21689 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
21690         LDKChannelHandshakeLimits this_ptr_conv;
21691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21692         this_ptr_conv.is_owned = false;
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21694         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
21695 }
21696
21697 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
21698         LDKChannelHandshakeLimits this_ptr_conv;
21699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21700         this_ptr_conv.is_owned = false;
21701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21702         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
21703         return ret_conv;
21704 }
21705
21706 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) {
21707         LDKChannelHandshakeLimits this_ptr_conv;
21708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21709         this_ptr_conv.is_owned = false;
21710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21711         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
21712 }
21713
21714 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) {
21715         LDKChannelHandshakeLimits this_ptr_conv;
21716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21717         this_ptr_conv.is_owned = false;
21718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21719         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
21720         return ret_conv;
21721 }
21722
21723 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) {
21724         LDKChannelHandshakeLimits this_ptr_conv;
21725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21726         this_ptr_conv.is_owned = false;
21727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21728         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21729 }
21730
21731 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
21732         LDKChannelHandshakeLimits this_ptr_conv;
21733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21734         this_ptr_conv.is_owned = false;
21735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21736         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
21737         return ret_conv;
21738 }
21739
21740 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) {
21741         LDKChannelHandshakeLimits this_ptr_conv;
21742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21743         this_ptr_conv.is_owned = false;
21744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21745         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
21746 }
21747
21748 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
21749         LDKChannelHandshakeLimits this_ptr_conv;
21750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21751         this_ptr_conv.is_owned = false;
21752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21753         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
21754         return ret_conv;
21755 }
21756
21757 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) {
21758         LDKChannelHandshakeLimits this_ptr_conv;
21759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21760         this_ptr_conv.is_owned = false;
21761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21762         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
21763 }
21764
21765 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
21766         LDKChannelHandshakeLimits this_ptr_conv;
21767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21768         this_ptr_conv.is_owned = false;
21769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21770         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
21771         return ret_conv;
21772 }
21773
21774 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
21775         LDKChannelHandshakeLimits this_ptr_conv;
21776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21777         this_ptr_conv.is_owned = false;
21778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21779         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
21780 }
21781
21782 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
21783         LDKChannelHandshakeLimits this_ptr_conv;
21784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21785         this_ptr_conv.is_owned = false;
21786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21787         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
21788         return ret_conv;
21789 }
21790
21791 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
21792         LDKChannelHandshakeLimits this_ptr_conv;
21793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21794         this_ptr_conv.is_owned = false;
21795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21796         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
21797 }
21798
21799 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
21800         LDKChannelHandshakeLimits this_ptr_conv;
21801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21802         this_ptr_conv.is_owned = false;
21803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21804         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
21805         return ret_conv;
21806 }
21807
21808 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
21809         LDKChannelHandshakeLimits this_ptr_conv;
21810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21811         this_ptr_conv.is_owned = false;
21812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21813         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
21814 }
21815
21816 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
21817         LDKChannelHandshakeLimits this_ptr_conv;
21818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21819         this_ptr_conv.is_owned = false;
21820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21821         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
21822         return ret_conv;
21823 }
21824
21825 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) {
21826         LDKChannelHandshakeLimits this_ptr_conv;
21827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21828         this_ptr_conv.is_owned = false;
21829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21830         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
21831 }
21832
21833 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) {
21834         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);
21835         uint32_t ret_ref = 0;
21836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21839         ret_ref = (uintptr_t)ret_var.inner;
21840         if (ret_var.is_owned) {
21841                 ret_ref |= 1;
21842         }
21843         return ret_ref;
21844 }
21845
21846 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
21847         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
21848 uint32_t ret_ref = 0;
21849 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21850 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21851 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21852 ret_ref = (uintptr_t)ret_var.inner;
21853 if (ret_var.is_owned) {
21854         ret_ref |= 1;
21855 }
21856         return ret_ref;
21857 }
21858 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
21859         LDKChannelHandshakeLimits arg_conv;
21860         arg_conv.inner = (void*)(arg & (~1));
21861         arg_conv.is_owned = false;
21862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21863         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
21864         return ret_conv;
21865 }
21866
21867 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
21868         LDKChannelHandshakeLimits orig_conv;
21869         orig_conv.inner = (void*)(orig & (~1));
21870         orig_conv.is_owned = false;
21871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21872         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
21873         uint32_t ret_ref = 0;
21874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21877         ret_ref = (uintptr_t)ret_var.inner;
21878         if (ret_var.is_owned) {
21879                 ret_ref |= 1;
21880         }
21881         return ret_ref;
21882 }
21883
21884 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
21885         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
21886         uint32_t ret_ref = 0;
21887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21890         ret_ref = (uintptr_t)ret_var.inner;
21891         if (ret_var.is_owned) {
21892                 ret_ref |= 1;
21893         }
21894         return ret_ref;
21895 }
21896
21897 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
21898         LDKChannelConfig this_obj_conv;
21899         this_obj_conv.inner = (void*)(this_obj & (~1));
21900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21902         ChannelConfig_free(this_obj_conv);
21903 }
21904
21905 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
21906         LDKChannelConfig this_ptr_conv;
21907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21908         this_ptr_conv.is_owned = false;
21909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21910         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
21911         return ret_conv;
21912 }
21913
21914 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) {
21915         LDKChannelConfig this_ptr_conv;
21916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21917         this_ptr_conv.is_owned = false;
21918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21919         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
21920 }
21921
21922 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
21923         LDKChannelConfig this_ptr_conv;
21924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21925         this_ptr_conv.is_owned = false;
21926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21927         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
21928         return ret_conv;
21929 }
21930
21931 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) {
21932         LDKChannelConfig this_ptr_conv;
21933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21934         this_ptr_conv.is_owned = false;
21935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21936         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
21937 }
21938
21939 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
21940         LDKChannelConfig this_ptr_conv;
21941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21942         this_ptr_conv.is_owned = false;
21943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21944         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
21945         return ret_conv;
21946 }
21947
21948 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21949         LDKChannelConfig this_ptr_conv;
21950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21951         this_ptr_conv.is_owned = false;
21952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21953         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
21954 }
21955
21956 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) {
21957         LDKChannelConfig this_ptr_conv;
21958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21959         this_ptr_conv.is_owned = false;
21960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21961         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21962         return ret_conv;
21963 }
21964
21965 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) {
21966         LDKChannelConfig this_ptr_conv;
21967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21968         this_ptr_conv.is_owned = false;
21969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21970         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21971 }
21972
21973 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) {
21974         LDKChannelConfig this_ptr_conv;
21975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21976         this_ptr_conv.is_owned = false;
21977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21978         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21979         return ret_conv;
21980 }
21981
21982 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) {
21983         LDKChannelConfig this_ptr_conv;
21984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21985         this_ptr_conv.is_owned = false;
21986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21987         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21988 }
21989
21990 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) {
21991         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);
21992         uint32_t ret_ref = 0;
21993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21996         ret_ref = (uintptr_t)ret_var.inner;
21997         if (ret_var.is_owned) {
21998                 ret_ref |= 1;
21999         }
22000         return ret_ref;
22001 }
22002
22003 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22004         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22005 uint32_t ret_ref = 0;
22006 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22007 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22008 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22009 ret_ref = (uintptr_t)ret_var.inner;
22010 if (ret_var.is_owned) {
22011         ret_ref |= 1;
22012 }
22013         return ret_ref;
22014 }
22015 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
22016         LDKChannelConfig arg_conv;
22017         arg_conv.inner = (void*)(arg & (~1));
22018         arg_conv.is_owned = false;
22019         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22020         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22021         return ret_conv;
22022 }
22023
22024 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
22025         LDKChannelConfig orig_conv;
22026         orig_conv.inner = (void*)(orig & (~1));
22027         orig_conv.is_owned = false;
22028         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22029         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22030         uint32_t ret_ref = 0;
22031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22034         ret_ref = (uintptr_t)ret_var.inner;
22035         if (ret_var.is_owned) {
22036                 ret_ref |= 1;
22037         }
22038         return ret_ref;
22039 }
22040
22041 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22042         LDKChannelConfig ret_var = ChannelConfig_default();
22043         uint32_t ret_ref = 0;
22044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22047         ret_ref = (uintptr_t)ret_var.inner;
22048         if (ret_var.is_owned) {
22049                 ret_ref |= 1;
22050         }
22051         return ret_ref;
22052 }
22053
22054 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
22055         LDKChannelConfig obj_conv;
22056         obj_conv.inner = (void*)(obj & (~1));
22057         obj_conv.is_owned = false;
22058         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22059         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22060         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22061         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22062         CVec_u8Z_free(ret_var);
22063         return ret_arr;
22064 }
22065
22066 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22067         LDKu8slice ser_ref;
22068         ser_ref.datalen = ser->arr_len;
22069         ser_ref.data = ser->elems;
22070         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22071         *ret_conv = ChannelConfig_read(ser_ref);
22072         FREE(ser);
22073         return (uint32_t)ret_conv;
22074 }
22075
22076 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
22077         LDKUserConfig this_obj_conv;
22078         this_obj_conv.inner = (void*)(this_obj & (~1));
22079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22081         UserConfig_free(this_obj_conv);
22082 }
22083
22084 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint32_t this_ptr) {
22085         LDKUserConfig this_ptr_conv;
22086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22087         this_ptr_conv.is_owned = false;
22088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22089         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22090         uint32_t ret_ref = 0;
22091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22094         ret_ref = (uintptr_t)ret_var.inner;
22095         if (ret_var.is_owned) {
22096                 ret_ref |= 1;
22097         }
22098         return ret_ref;
22099 }
22100
22101 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint32_t this_ptr, uint32_t val) {
22102         LDKUserConfig this_ptr_conv;
22103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22104         this_ptr_conv.is_owned = false;
22105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22106         LDKChannelHandshakeConfig val_conv;
22107         val_conv.inner = (void*)(val & (~1));
22108         val_conv.is_owned = (val & 1) || (val == 0);
22109         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22110         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22111         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22112 }
22113
22114 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint32_t this_ptr) {
22115         LDKUserConfig this_ptr_conv;
22116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22117         this_ptr_conv.is_owned = false;
22118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22119         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22120         uint32_t ret_ref = 0;
22121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22124         ret_ref = (uintptr_t)ret_var.inner;
22125         if (ret_var.is_owned) {
22126                 ret_ref |= 1;
22127         }
22128         return ret_ref;
22129 }
22130
22131 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint32_t this_ptr, uint32_t val) {
22132         LDKUserConfig this_ptr_conv;
22133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22134         this_ptr_conv.is_owned = false;
22135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22136         LDKChannelHandshakeLimits val_conv;
22137         val_conv.inner = (void*)(val & (~1));
22138         val_conv.is_owned = (val & 1) || (val == 0);
22139         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22140         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22141         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22142 }
22143
22144 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint32_t this_ptr) {
22145         LDKUserConfig this_ptr_conv;
22146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22147         this_ptr_conv.is_owned = false;
22148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22149         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22150         uint32_t ret_ref = 0;
22151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22154         ret_ref = (uintptr_t)ret_var.inner;
22155         if (ret_var.is_owned) {
22156                 ret_ref |= 1;
22157         }
22158         return ret_ref;
22159 }
22160
22161 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint32_t this_ptr, uint32_t val) {
22162         LDKUserConfig this_ptr_conv;
22163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22164         this_ptr_conv.is_owned = false;
22165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22166         LDKChannelConfig val_conv;
22167         val_conv.inner = (void*)(val & (~1));
22168         val_conv.is_owned = (val & 1) || (val == 0);
22169         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22170         val_conv = ChannelConfig_clone(&val_conv);
22171         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22172 }
22173
22174 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
22175         LDKUserConfig this_ptr_conv;
22176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22177         this_ptr_conv.is_owned = false;
22178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22179         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22180         return ret_conv;
22181 }
22182
22183 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) {
22184         LDKUserConfig this_ptr_conv;
22185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22186         this_ptr_conv.is_owned = false;
22187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22188         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22189 }
22190
22191 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
22192         LDKUserConfig this_ptr_conv;
22193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22194         this_ptr_conv.is_owned = false;
22195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22196         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22197         return ret_conv;
22198 }
22199
22200 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22201         LDKUserConfig this_ptr_conv;
22202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22203         this_ptr_conv.is_owned = false;
22204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22205         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22206 }
22207
22208 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
22209         LDKUserConfig this_ptr_conv;
22210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22211         this_ptr_conv.is_owned = false;
22212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22213         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22214         return ret_conv;
22215 }
22216
22217 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22218         LDKUserConfig this_ptr_conv;
22219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22220         this_ptr_conv.is_owned = false;
22221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22222         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22223 }
22224
22225 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) {
22226         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22227         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
22228         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
22229         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22230         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22231         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22232         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
22233         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
22234         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22235         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22236         LDKChannelConfig channel_config_arg_conv;
22237         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
22238         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
22239         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22240         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22241         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);
22242         uint32_t ret_ref = 0;
22243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22246         ret_ref = (uintptr_t)ret_var.inner;
22247         if (ret_var.is_owned) {
22248                 ret_ref |= 1;
22249         }
22250         return ret_ref;
22251 }
22252
22253 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22254         LDKUserConfig ret_var = UserConfig_clone(arg);
22255 uint32_t ret_ref = 0;
22256 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22257 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22258 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22259 ret_ref = (uintptr_t)ret_var.inner;
22260 if (ret_var.is_owned) {
22261         ret_ref |= 1;
22262 }
22263         return ret_ref;
22264 }
22265 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
22266         LDKUserConfig arg_conv;
22267         arg_conv.inner = (void*)(arg & (~1));
22268         arg_conv.is_owned = false;
22269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22270         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22271         return ret_conv;
22272 }
22273
22274 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
22275         LDKUserConfig orig_conv;
22276         orig_conv.inner = (void*)(orig & (~1));
22277         orig_conv.is_owned = false;
22278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22279         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22280         uint32_t ret_ref = 0;
22281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22284         ret_ref = (uintptr_t)ret_var.inner;
22285         if (ret_var.is_owned) {
22286                 ret_ref |= 1;
22287         }
22288         return ret_ref;
22289 }
22290
22291 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22292         LDKUserConfig ret_var = UserConfig_default();
22293         uint32_t ret_ref = 0;
22294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22297         ret_ref = (uintptr_t)ret_var.inner;
22298         if (ret_var.is_owned) {
22299                 ret_ref |= 1;
22300         }
22301         return ret_ref;
22302 }
22303
22304 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
22305         LDKBestBlock this_obj_conv;
22306         this_obj_conv.inner = (void*)(this_obj & (~1));
22307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22309         BestBlock_free(this_obj_conv);
22310 }
22311
22312 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22313         LDKBestBlock ret_var = BestBlock_clone(arg);
22314 uint32_t ret_ref = 0;
22315 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22316 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22317 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22318 ret_ref = (uintptr_t)ret_var.inner;
22319 if (ret_var.is_owned) {
22320         ret_ref |= 1;
22321 }
22322         return ret_ref;
22323 }
22324 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
22325         LDKBestBlock arg_conv;
22326         arg_conv.inner = (void*)(arg & (~1));
22327         arg_conv.is_owned = false;
22328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22329         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22330         return ret_conv;
22331 }
22332
22333 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
22334         LDKBestBlock orig_conv;
22335         orig_conv.inner = (void*)(orig & (~1));
22336         orig_conv.is_owned = false;
22337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22338         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
22339         uint32_t ret_ref = 0;
22340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22343         ret_ref = (uintptr_t)ret_var.inner;
22344         if (ret_var.is_owned) {
22345                 ret_ref |= 1;
22346         }
22347         return ret_ref;
22348 }
22349
22350 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22351         LDKNetwork network_conv = LDKNetwork_from_js(network);
22352         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22353         uint32_t ret_ref = 0;
22354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22357         ret_ref = (uintptr_t)ret_var.inner;
22358         if (ret_var.is_owned) {
22359                 ret_ref |= 1;
22360         }
22361         return ret_ref;
22362 }
22363
22364 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22365         LDKThirtyTwoBytes block_hash_ref;
22366         CHECK(block_hash->arr_len == 32);
22367         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22368         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22369         uint32_t ret_ref = 0;
22370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22373         ret_ref = (uintptr_t)ret_var.inner;
22374         if (ret_var.is_owned) {
22375                 ret_ref |= 1;
22376         }
22377         return ret_ref;
22378 }
22379
22380 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22381         LDKBestBlock this_arg_conv;
22382         this_arg_conv.inner = (void*)(this_arg & (~1));
22383         this_arg_conv.is_owned = false;
22384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22385         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22386         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22387         return ret_arr;
22388 }
22389
22390 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22391         LDKBestBlock this_arg_conv;
22392         this_arg_conv.inner = (void*)(this_arg & (~1));
22393         this_arg_conv.is_owned = false;
22394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22395         int32_t ret_conv = BestBlock_height(&this_arg_conv);
22396         return ret_conv;
22397 }
22398
22399 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
22400         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
22401         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
22402         return ret_conv;
22403 }
22404
22405 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
22406         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
22407         return ret_conv;
22408 }
22409
22410 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
22411         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
22412         return ret_conv;
22413 }
22414
22415 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
22416         if ((this_ptr & 1) != 0) return;
22417         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22418         CHECK_ACCESS(this_ptr_ptr);
22419         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
22420         FREE((void*)this_ptr);
22421         Access_free(this_ptr_conv);
22422 }
22423
22424 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
22425         if ((this_ptr & 1) != 0) return;
22426         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22427         CHECK_ACCESS(this_ptr_ptr);
22428         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
22429         FREE((void*)this_ptr);
22430         Listen_free(this_ptr_conv);
22431 }
22432
22433 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
22434         if ((this_ptr & 1) != 0) return;
22435         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22436         CHECK_ACCESS(this_ptr_ptr);
22437         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
22438         FREE((void*)this_ptr);
22439         Confirm_free(this_ptr_conv);
22440 }
22441
22442 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
22443         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
22444         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
22445         return ret_conv;
22446 }
22447
22448 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
22449         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
22450         return ret_conv;
22451 }
22452
22453 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
22454         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
22455         return ret_conv;
22456 }
22457
22458 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
22459         if ((this_ptr & 1) != 0) return;
22460         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22461         CHECK_ACCESS(this_ptr_ptr);
22462         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
22463         FREE((void*)this_ptr);
22464         Watch_free(this_ptr_conv);
22465 }
22466
22467 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
22468         if ((this_ptr & 1) != 0) return;
22469         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22470         CHECK_ACCESS(this_ptr_ptr);
22471         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
22472         FREE((void*)this_ptr);
22473         Filter_free(this_ptr_conv);
22474 }
22475
22476 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
22477         LDKWatchedOutput this_obj_conv;
22478         this_obj_conv.inner = (void*)(this_obj & (~1));
22479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22481         WatchedOutput_free(this_obj_conv);
22482 }
22483
22484 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
22485         LDKWatchedOutput this_ptr_conv;
22486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22487         this_ptr_conv.is_owned = false;
22488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22489         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22490         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
22491         return ret_arr;
22492 }
22493
22494 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
22495         LDKWatchedOutput this_ptr_conv;
22496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22497         this_ptr_conv.is_owned = false;
22498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22499         LDKThirtyTwoBytes val_ref;
22500         CHECK(val->arr_len == 32);
22501         memcpy(val_ref.data, val->elems, 32); FREE(val);
22502         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
22503 }
22504
22505 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
22506         LDKWatchedOutput this_ptr_conv;
22507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22508         this_ptr_conv.is_owned = false;
22509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22510         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
22511         uint32_t ret_ref = 0;
22512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22515         ret_ref = (uintptr_t)ret_var.inner;
22516         if (ret_var.is_owned) {
22517                 ret_ref |= 1;
22518         }
22519         return ret_ref;
22520 }
22521
22522 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
22523         LDKWatchedOutput this_ptr_conv;
22524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22525         this_ptr_conv.is_owned = false;
22526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22527         LDKOutPoint val_conv;
22528         val_conv.inner = (void*)(val & (~1));
22529         val_conv.is_owned = (val & 1) || (val == 0);
22530         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22531         val_conv = OutPoint_clone(&val_conv);
22532         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
22533 }
22534
22535 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
22536         LDKWatchedOutput this_ptr_conv;
22537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22538         this_ptr_conv.is_owned = false;
22539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22540         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
22541         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22542         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22543         return ret_arr;
22544 }
22545
22546 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
22547         LDKWatchedOutput this_ptr_conv;
22548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22549         this_ptr_conv.is_owned = false;
22550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22551         LDKCVec_u8Z val_ref;
22552         val_ref.datalen = val->arr_len;
22553         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
22554         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
22555         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
22556 }
22557
22558 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) {
22559         LDKThirtyTwoBytes block_hash_arg_ref;
22560         CHECK(block_hash_arg->arr_len == 32);
22561         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
22562         LDKOutPoint outpoint_arg_conv;
22563         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22564         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22565         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22566         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22567         LDKCVec_u8Z script_pubkey_arg_ref;
22568         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
22569         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
22570         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
22571         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
22572         uint32_t ret_ref = 0;
22573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22576         ret_ref = (uintptr_t)ret_var.inner;
22577         if (ret_var.is_owned) {
22578                 ret_ref |= 1;
22579         }
22580         return ret_ref;
22581 }
22582
22583 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
22584         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
22585 uint32_t ret_ref = 0;
22586 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22587 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22588 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22589 ret_ref = (uintptr_t)ret_var.inner;
22590 if (ret_var.is_owned) {
22591         ret_ref |= 1;
22592 }
22593         return ret_ref;
22594 }
22595 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
22596         LDKWatchedOutput arg_conv;
22597         arg_conv.inner = (void*)(arg & (~1));
22598         arg_conv.is_owned = false;
22599         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22600         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
22601         return ret_conv;
22602 }
22603
22604 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
22605         LDKWatchedOutput orig_conv;
22606         orig_conv.inner = (void*)(orig & (~1));
22607         orig_conv.is_owned = false;
22608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22609         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
22610         uint32_t ret_ref = 0;
22611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22614         ret_ref = (uintptr_t)ret_var.inner;
22615         if (ret_var.is_owned) {
22616                 ret_ref |= 1;
22617         }
22618         return ret_ref;
22619 }
22620
22621 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
22622         LDKWatchedOutput o_conv;
22623         o_conv.inner = (void*)(o & (~1));
22624         o_conv.is_owned = false;
22625         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22626         int64_t ret_conv = WatchedOutput_hash(&o_conv);
22627         return ret_conv;
22628 }
22629
22630 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
22631         if ((this_ptr & 1) != 0) return;
22632         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22633         CHECK_ACCESS(this_ptr_ptr);
22634         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
22635         FREE((void*)this_ptr);
22636         BroadcasterInterface_free(this_ptr_conv);
22637 }
22638
22639 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
22640         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
22641         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
22642         return ret_conv;
22643 }
22644
22645 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
22646         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
22647         return ret_conv;
22648 }
22649
22650 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
22651         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
22652         return ret_conv;
22653 }
22654
22655 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
22656         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
22657         return ret_conv;
22658 }
22659
22660 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
22661         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
22662         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
22663         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
22664         return ret_conv;
22665 }
22666
22667 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
22668         if ((this_ptr & 1) != 0) return;
22669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22670         CHECK_ACCESS(this_ptr_ptr);
22671         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
22672         FREE((void*)this_ptr);
22673         FeeEstimator_free(this_ptr_conv);
22674 }
22675
22676 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
22677         LDKMonitorUpdateId this_obj_conv;
22678         this_obj_conv.inner = (void*)(this_obj & (~1));
22679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22681         MonitorUpdateId_free(this_obj_conv);
22682 }
22683
22684 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
22685         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
22686 uint32_t ret_ref = 0;
22687 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22688 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22689 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22690 ret_ref = (uintptr_t)ret_var.inner;
22691 if (ret_var.is_owned) {
22692         ret_ref |= 1;
22693 }
22694         return ret_ref;
22695 }
22696 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
22697         LDKMonitorUpdateId arg_conv;
22698         arg_conv.inner = (void*)(arg & (~1));
22699         arg_conv.is_owned = false;
22700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22701         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
22702         return ret_conv;
22703 }
22704
22705 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
22706         LDKMonitorUpdateId orig_conv;
22707         orig_conv.inner = (void*)(orig & (~1));
22708         orig_conv.is_owned = false;
22709         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22710         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
22711         uint32_t ret_ref = 0;
22712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22715         ret_ref = (uintptr_t)ret_var.inner;
22716         if (ret_var.is_owned) {
22717                 ret_ref |= 1;
22718         }
22719         return ret_ref;
22720 }
22721
22722 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
22723         LDKMonitorUpdateId o_conv;
22724         o_conv.inner = (void*)(o & (~1));
22725         o_conv.is_owned = false;
22726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22727         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
22728         return ret_conv;
22729 }
22730
22731 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
22732         LDKMonitorUpdateId a_conv;
22733         a_conv.inner = (void*)(a & (~1));
22734         a_conv.is_owned = false;
22735         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22736         LDKMonitorUpdateId b_conv;
22737         b_conv.inner = (void*)(b & (~1));
22738         b_conv.is_owned = false;
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22740         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
22741         return ret_conv;
22742 }
22743
22744 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
22745         if ((this_ptr & 1) != 0) return;
22746         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22747         CHECK_ACCESS(this_ptr_ptr);
22748         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
22749         FREE((void*)this_ptr);
22750         Persist_free(this_ptr_conv);
22751 }
22752
22753 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
22754         LDKLockedChannelMonitor this_obj_conv;
22755         this_obj_conv.inner = (void*)(this_obj & (~1));
22756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22758         LockedChannelMonitor_free(this_obj_conv);
22759 }
22760
22761 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
22762         LDKChainMonitor this_obj_conv;
22763         this_obj_conv.inner = (void*)(this_obj & (~1));
22764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22766         ChainMonitor_free(this_obj_conv);
22767 }
22768
22769 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) {
22770         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
22771         CHECK_ACCESS(chain_source_ptr);
22772         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
22773         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
22774         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
22775                 // Manually implement clone for Java trait instances
22776                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
22777                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22778                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
22779                 }
22780         }
22781         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22782         CHECK_ACCESS(broadcaster_ptr);
22783         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22784         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22786                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22787         }
22788         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22789         CHECK_ACCESS(logger_ptr);
22790         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22791         if (logger_conv.free == LDKLogger_JCalls_free) {
22792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22793                 LDKLogger_JCalls_cloned(&logger_conv);
22794         }
22795         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
22796         CHECK_ACCESS(feeest_ptr);
22797         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
22798         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
22799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22800                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
22801         }
22802         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
22803         CHECK_ACCESS(persister_ptr);
22804         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
22805         if (persister_conv.free == LDKPersist_JCalls_free) {
22806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22807                 LDKPersist_JCalls_cloned(&persister_conv);
22808         }
22809         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
22810         uint32_t ret_ref = 0;
22811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22814         ret_ref = (uintptr_t)ret_var.inner;
22815         if (ret_var.is_owned) {
22816                 ret_ref |= 1;
22817         }
22818         return ret_ref;
22819 }
22820
22821 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
22822         LDKChainMonitor this_arg_conv;
22823         this_arg_conv.inner = (void*)(this_arg & (~1));
22824         this_arg_conv.is_owned = false;
22825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22826         LDKCVec_ChannelDetailsZ ignored_channels_constr;
22827         ignored_channels_constr.datalen = ignored_channels->arr_len;
22828         if (ignored_channels_constr.datalen > 0)
22829                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22830         else
22831                 ignored_channels_constr.data = NULL;
22832         uint32_t* ignored_channels_vals = ignored_channels->elems;
22833         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
22834                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
22835                 LDKChannelDetails ignored_channels_conv_16_conv;
22836                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
22837                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
22838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
22839                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
22840                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
22841         }
22842         FREE(ignored_channels);
22843         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
22844         uint32_tArray ret_arr = NULL;
22845         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22846         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22847         for (size_t j = 0; j < ret_var.datalen; j++) {
22848                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22849                 *ret_conv_9_copy = ret_var.data[j];
22850                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22851                 ret_arr_ptr[j] = ret_conv_9_ref;
22852         }
22853         
22854         FREE(ret_var.data);
22855         return ret_arr;
22856 }
22857
22858 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
22859         LDKChainMonitor this_arg_conv;
22860         this_arg_conv.inner = (void*)(this_arg & (~1));
22861         this_arg_conv.is_owned = false;
22862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22863         LDKOutPoint funding_txo_conv;
22864         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22865         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22866         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22867         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22868         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22869         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
22870         return (uint32_t)ret_conv;
22871 }
22872
22873 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
22874         LDKChainMonitor this_arg_conv;
22875         this_arg_conv.inner = (void*)(this_arg & (~1));
22876         this_arg_conv.is_owned = false;
22877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22878         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
22879         uint32_tArray ret_arr = NULL;
22880         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22881         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22882         for (size_t k = 0; k < ret_var.datalen; k++) {
22883                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
22884                 uint32_t ret_conv_10_ref = 0;
22885                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22886                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22887                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
22888                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
22889                 if (ret_conv_10_var.is_owned) {
22890                         ret_conv_10_ref |= 1;
22891                 }
22892                 ret_arr_ptr[k] = ret_conv_10_ref;
22893         }
22894         
22895         FREE(ret_var.data);
22896         return ret_arr;
22897 }
22898
22899 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) {
22900         LDKChainMonitor this_arg_conv;
22901         this_arg_conv.inner = (void*)(this_arg & (~1));
22902         this_arg_conv.is_owned = false;
22903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22904         LDKOutPoint funding_txo_conv;
22905         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22906         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22907         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22908         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22909         LDKMonitorUpdateId completed_update_id_conv;
22910         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
22911         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
22912         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
22913         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
22914         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
22915         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
22916         return (uint32_t)ret_conv;
22917 }
22918
22919 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
22920         LDKChainMonitor this_arg_conv;
22921         this_arg_conv.inner = (void*)(this_arg & (~1));
22922         this_arg_conv.is_owned = false;
22923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22924         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22925         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
22926         return (uint32_t)ret_ret;
22927 }
22928
22929 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
22930         LDKChainMonitor this_arg_conv;
22931         this_arg_conv.inner = (void*)(this_arg & (~1));
22932         this_arg_conv.is_owned = false;
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22934         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22935         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
22936         return (uint32_t)ret_ret;
22937 }
22938
22939 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
22940         LDKChainMonitor this_arg_conv;
22941         this_arg_conv.inner = (void*)(this_arg & (~1));
22942         this_arg_conv.is_owned = false;
22943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22944         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
22945         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
22946         return (uint32_t)ret_ret;
22947 }
22948
22949 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
22950         LDKChainMonitor this_arg_conv;
22951         this_arg_conv.inner = (void*)(this_arg & (~1));
22952         this_arg_conv.is_owned = false;
22953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22954         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22955         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
22956         return (uint32_t)ret_ret;
22957 }
22958
22959 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
22960         LDKChannelMonitorUpdate this_obj_conv;
22961         this_obj_conv.inner = (void*)(this_obj & (~1));
22962         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22964         ChannelMonitorUpdate_free(this_obj_conv);
22965 }
22966
22967 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
22968         LDKChannelMonitorUpdate this_ptr_conv;
22969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22970         this_ptr_conv.is_owned = false;
22971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22972         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22973         return ret_conv;
22974 }
22975
22976 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
22977         LDKChannelMonitorUpdate this_ptr_conv;
22978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22979         this_ptr_conv.is_owned = false;
22980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22981         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22982 }
22983
22984 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22985         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22986 uint32_t ret_ref = 0;
22987 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22988 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22989 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22990 ret_ref = (uintptr_t)ret_var.inner;
22991 if (ret_var.is_owned) {
22992         ret_ref |= 1;
22993 }
22994         return ret_ref;
22995 }
22996 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
22997         LDKChannelMonitorUpdate arg_conv;
22998         arg_conv.inner = (void*)(arg & (~1));
22999         arg_conv.is_owned = false;
23000         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23001         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23002         return ret_conv;
23003 }
23004
23005 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
23006         LDKChannelMonitorUpdate orig_conv;
23007         orig_conv.inner = (void*)(orig & (~1));
23008         orig_conv.is_owned = false;
23009         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23010         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23011         uint32_t ret_ref = 0;
23012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23015         ret_ref = (uintptr_t)ret_var.inner;
23016         if (ret_var.is_owned) {
23017                 ret_ref |= 1;
23018         }
23019         return ret_ref;
23020 }
23021
23022 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
23023         LDKChannelMonitorUpdate obj_conv;
23024         obj_conv.inner = (void*)(obj & (~1));
23025         obj_conv.is_owned = false;
23026         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23027         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23028         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23029         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23030         CVec_u8Z_free(ret_var);
23031         return ret_arr;
23032 }
23033
23034 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23035         LDKu8slice ser_ref;
23036         ser_ref.datalen = ser->arr_len;
23037         ser_ref.data = ser->elems;
23038         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23039         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23040         FREE(ser);
23041         return (uint32_t)ret_conv;
23042 }
23043
23044 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
23045         if ((this_ptr & 1) != 0) return;
23046         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23047         CHECK_ACCESS(this_ptr_ptr);
23048         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23049         FREE((void*)this_ptr);
23050         MonitorEvent_free(this_ptr_conv);
23051 }
23052
23053 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23054         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23055         *ret_copy = MonitorEvent_clone(arg);
23056 uint32_t ret_ref = (uintptr_t)ret_copy;
23057         return ret_ref;
23058 }
23059 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
23060         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
23061         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23062         return ret_conv;
23063 }
23064
23065 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
23066         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
23067         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23068         *ret_copy = MonitorEvent_clone(orig_conv);
23069         uint32_t ret_ref = (uintptr_t)ret_copy;
23070         return ret_ref;
23071 }
23072
23073 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
23074         LDKHTLCUpdate a_conv;
23075         a_conv.inner = (void*)(a & (~1));
23076         a_conv.is_owned = (a & 1) || (a == 0);
23077         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23078         a_conv = HTLCUpdate_clone(&a_conv);
23079         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23080         *ret_copy = MonitorEvent_htlcevent(a_conv);
23081         uint32_t ret_ref = (uintptr_t)ret_copy;
23082         return ret_ref;
23083 }
23084
23085 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
23086         LDKOutPoint a_conv;
23087         a_conv.inner = (void*)(a & (~1));
23088         a_conv.is_owned = (a & 1) || (a == 0);
23089         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23090         a_conv = OutPoint_clone(&a_conv);
23091         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23092         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23093         uint32_t ret_ref = (uintptr_t)ret_copy;
23094         return ret_ref;
23095 }
23096
23097 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
23098         LDKOutPoint funding_txo_conv;
23099         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23100         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23101         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23102         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23103         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23104         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23105         uint32_t ret_ref = (uintptr_t)ret_copy;
23106         return ret_ref;
23107 }
23108
23109 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
23110         LDKOutPoint a_conv;
23111         a_conv.inner = (void*)(a & (~1));
23112         a_conv.is_owned = (a & 1) || (a == 0);
23113         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23114         a_conv = OutPoint_clone(&a_conv);
23115         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23116         *ret_copy = MonitorEvent_update_failed(a_conv);
23117         uint32_t ret_ref = (uintptr_t)ret_copy;
23118         return ret_ref;
23119 }
23120
23121 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
23122         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
23123         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23124         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23125         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23126         CVec_u8Z_free(ret_var);
23127         return ret_arr;
23128 }
23129
23130 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23131         LDKu8slice ser_ref;
23132         ser_ref.datalen = ser->arr_len;
23133         ser_ref.data = ser->elems;
23134         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23135         *ret_conv = MonitorEvent_read(ser_ref);
23136         FREE(ser);
23137         return (uint32_t)ret_conv;
23138 }
23139
23140 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
23141         LDKHTLCUpdate this_obj_conv;
23142         this_obj_conv.inner = (void*)(this_obj & (~1));
23143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23145         HTLCUpdate_free(this_obj_conv);
23146 }
23147
23148 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23149         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23150 uint32_t ret_ref = 0;
23151 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23152 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23153 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23154 ret_ref = (uintptr_t)ret_var.inner;
23155 if (ret_var.is_owned) {
23156         ret_ref |= 1;
23157 }
23158         return ret_ref;
23159 }
23160 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
23161         LDKHTLCUpdate arg_conv;
23162         arg_conv.inner = (void*)(arg & (~1));
23163         arg_conv.is_owned = false;
23164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23165         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23166         return ret_conv;
23167 }
23168
23169 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
23170         LDKHTLCUpdate orig_conv;
23171         orig_conv.inner = (void*)(orig & (~1));
23172         orig_conv.is_owned = false;
23173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23174         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23175         uint32_t ret_ref = 0;
23176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23179         ret_ref = (uintptr_t)ret_var.inner;
23180         if (ret_var.is_owned) {
23181                 ret_ref |= 1;
23182         }
23183         return ret_ref;
23184 }
23185
23186 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
23187         LDKHTLCUpdate obj_conv;
23188         obj_conv.inner = (void*)(obj & (~1));
23189         obj_conv.is_owned = false;
23190         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23191         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23192         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23193         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23194         CVec_u8Z_free(ret_var);
23195         return ret_arr;
23196 }
23197
23198 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23199         LDKu8slice ser_ref;
23200         ser_ref.datalen = ser->arr_len;
23201         ser_ref.data = ser->elems;
23202         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23203         *ret_conv = HTLCUpdate_read(ser_ref);
23204         FREE(ser);
23205         return (uint32_t)ret_conv;
23206 }
23207
23208 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
23209         if ((this_ptr & 1) != 0) return;
23210         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23211         CHECK_ACCESS(this_ptr_ptr);
23212         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23213         FREE((void*)this_ptr);
23214         Balance_free(this_ptr_conv);
23215 }
23216
23217 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23218         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23219         *ret_copy = Balance_clone(arg);
23220 uint32_t ret_ref = (uintptr_t)ret_copy;
23221         return ret_ref;
23222 }
23223 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
23224         LDKBalance* arg_conv = (LDKBalance*)arg;
23225         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
23226         return ret_conv;
23227 }
23228
23229 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
23230         LDKBalance* orig_conv = (LDKBalance*)orig;
23231         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23232         *ret_copy = Balance_clone(orig_conv);
23233         uint32_t ret_ref = (uintptr_t)ret_copy;
23234         return ret_ref;
23235 }
23236
23237 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23238         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23239         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23240         uint32_t ret_ref = (uintptr_t)ret_copy;
23241         return ret_ref;
23242 }
23243
23244 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23245         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23246         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23247         uint32_t ret_ref = (uintptr_t)ret_copy;
23248         return ret_ref;
23249 }
23250
23251 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23252         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23253         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23254         uint32_t ret_ref = (uintptr_t)ret_copy;
23255         return ret_ref;
23256 }
23257
23258 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) {
23259         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23260         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
23261         uint32_t ret_ref = (uintptr_t)ret_copy;
23262         return ret_ref;
23263 }
23264
23265 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
23266         LDKBalance* a_conv = (LDKBalance*)a;
23267         LDKBalance* b_conv = (LDKBalance*)b;
23268         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23269         return ret_conv;
23270 }
23271
23272 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
23273         LDKChannelMonitor this_obj_conv;
23274         this_obj_conv.inner = (void*)(this_obj & (~1));
23275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23277         ChannelMonitor_free(this_obj_conv);
23278 }
23279
23280 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23281         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23282 uint32_t ret_ref = 0;
23283 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23284 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23286 ret_ref = (uintptr_t)ret_var.inner;
23287 if (ret_var.is_owned) {
23288         ret_ref |= 1;
23289 }
23290         return ret_ref;
23291 }
23292 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
23293         LDKChannelMonitor arg_conv;
23294         arg_conv.inner = (void*)(arg & (~1));
23295         arg_conv.is_owned = false;
23296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23297         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23298         return ret_conv;
23299 }
23300
23301 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
23302         LDKChannelMonitor orig_conv;
23303         orig_conv.inner = (void*)(orig & (~1));
23304         orig_conv.is_owned = false;
23305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23306         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23307         uint32_t ret_ref = 0;
23308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23311         ret_ref = (uintptr_t)ret_var.inner;
23312         if (ret_var.is_owned) {
23313                 ret_ref |= 1;
23314         }
23315         return ret_ref;
23316 }
23317
23318 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
23319         LDKChannelMonitor obj_conv;
23320         obj_conv.inner = (void*)(obj & (~1));
23321         obj_conv.is_owned = false;
23322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23323         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23324         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23325         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23326         CVec_u8Z_free(ret_var);
23327         return ret_arr;
23328 }
23329
23330 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) {
23331         LDKChannelMonitor this_arg_conv;
23332         this_arg_conv.inner = (void*)(this_arg & (~1));
23333         this_arg_conv.is_owned = false;
23334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23335         LDKChannelMonitorUpdate updates_conv;
23336         updates_conv.inner = (void*)(updates & (~1));
23337         updates_conv.is_owned = false;
23338         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23339         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23340         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
23341         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23342         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23343         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
23344         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
23345         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23346         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23347         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23348         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23349         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23350         return (uint32_t)ret_conv;
23351 }
23352
23353 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23354         LDKChannelMonitor this_arg_conv;
23355         this_arg_conv.inner = (void*)(this_arg & (~1));
23356         this_arg_conv.is_owned = false;
23357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23358         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23359         return ret_conv;
23360 }
23361
23362 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23363         LDKChannelMonitor this_arg_conv;
23364         this_arg_conv.inner = (void*)(this_arg & (~1));
23365         this_arg_conv.is_owned = false;
23366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23367         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23368         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23369         return ((uint32_t)ret_conv);
23370 }
23371
23372 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23373         LDKChannelMonitor this_arg_conv;
23374         this_arg_conv.inner = (void*)(this_arg & (~1));
23375         this_arg_conv.is_owned = false;
23376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23377         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23378         uint32_tArray ret_arr = NULL;
23379         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23380         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23381         for (size_t o = 0; o < ret_var.datalen; o++) {
23382                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23383                 *ret_conv_40_conv = ret_var.data[o];
23384                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23385         }
23386         
23387         FREE(ret_var.data);
23388         return ret_arr;
23389 }
23390
23391 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
23392         LDKChannelMonitor this_arg_conv;
23393         this_arg_conv.inner = (void*)(this_arg & (~1));
23394         this_arg_conv.is_owned = false;
23395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23396         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
23397         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
23398         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
23399         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
23400 }
23401
23402 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) {
23403         LDKChannelMonitor this_arg_conv;
23404         this_arg_conv.inner = (void*)(this_arg & (~1));
23405         this_arg_conv.is_owned = false;
23406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23407         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
23408         uint32_tArray ret_arr = NULL;
23409         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23410         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23411         for (size_t o = 0; o < ret_var.datalen; o++) {
23412                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23413                 *ret_conv_14_copy = ret_var.data[o];
23414                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
23415                 ret_arr_ptr[o] = ret_conv_14_ref;
23416         }
23417         
23418         FREE(ret_var.data);
23419         return ret_arr;
23420 }
23421
23422 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
23423         LDKChannelMonitor this_arg_conv;
23424         this_arg_conv.inner = (void*)(this_arg & (~1));
23425         this_arg_conv.is_owned = false;
23426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23427         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
23428         uint32_tArray ret_arr = NULL;
23429         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23430         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23431         for (size_t h = 0; h < ret_var.datalen; h++) {
23432                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23433                 *ret_conv_7_copy = ret_var.data[h];
23434                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
23435                 ret_arr_ptr[h] = ret_conv_7_ref;
23436         }
23437         
23438         FREE(ret_var.data);
23439         return ret_arr;
23440 }
23441
23442 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) {
23443         LDKChannelMonitor this_arg_conv;
23444         this_arg_conv.inner = (void*)(this_arg & (~1));
23445         this_arg_conv.is_owned = false;
23446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23447         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23448         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23449         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23450         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
23451         ptrArray ret_arr = NULL;
23452         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23453         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23454         for (size_t m = 0; m < ret_var.datalen; m++) {
23455                 LDKTransaction ret_conv_12_var = ret_var.data[m];
23456                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
23457                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
23458                 Transaction_free(ret_conv_12_var);
23459                 ret_arr_ptr[m] = ret_conv_12_arr;
23460         }
23461         
23462         FREE(ret_var.data);
23463         return ret_arr;
23464 }
23465
23466 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) {
23467         LDKChannelMonitor this_arg_conv;
23468         this_arg_conv.inner = (void*)(this_arg & (~1));
23469         this_arg_conv.is_owned = false;
23470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23471         unsigned char header_arr[80];
23472         CHECK(header->arr_len == 80);
23473         memcpy(header_arr, header->elems, 80); FREE(header);
23474         unsigned char (*header_ref)[80] = &header_arr;
23475         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23476         txdata_constr.datalen = txdata->arr_len;
23477         if (txdata_constr.datalen > 0)
23478                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23479         else
23480                 txdata_constr.data = NULL;
23481         uint32_t* txdata_vals = txdata->elems;
23482         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23483                 uint32_t txdata_conv_28 = txdata_vals[c];
23484                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23485                 CHECK_ACCESS(txdata_conv_28_ptr);
23486                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23487                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23488                 txdata_constr.data[c] = txdata_conv_28_conv;
23489         }
23490         FREE(txdata);
23491         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23492         CHECK_ACCESS(broadcaster_ptr);
23493         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23494         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23496                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23497         }
23498         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23499         CHECK_ACCESS(fee_estimator_ptr);
23500         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23501         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23503                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23504         }
23505         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23506         CHECK_ACCESS(logger_ptr);
23507         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23508         if (logger_conv.free == LDKLogger_JCalls_free) {
23509                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23510                 LDKLogger_JCalls_cloned(&logger_conv);
23511         }
23512         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);
23513         uint32_tArray ret_arr = NULL;
23514         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23515         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23516         for (size_t n = 0; n < ret_var.datalen; n++) {
23517                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23518                 *ret_conv_39_conv = ret_var.data[n];
23519                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23520         }
23521         
23522         FREE(ret_var.data);
23523         return ret_arr;
23524 }
23525
23526 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) {
23527         LDKChannelMonitor this_arg_conv;
23528         this_arg_conv.inner = (void*)(this_arg & (~1));
23529         this_arg_conv.is_owned = false;
23530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23531         unsigned char header_arr[80];
23532         CHECK(header->arr_len == 80);
23533         memcpy(header_arr, header->elems, 80); FREE(header);
23534         unsigned char (*header_ref)[80] = &header_arr;
23535         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23536         CHECK_ACCESS(broadcaster_ptr);
23537         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23538         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23539                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23540                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23541         }
23542         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23543         CHECK_ACCESS(fee_estimator_ptr);
23544         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23545         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23546                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23547                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23548         }
23549         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23550         CHECK_ACCESS(logger_ptr);
23551         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23552         if (logger_conv.free == LDKLogger_JCalls_free) {
23553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23554                 LDKLogger_JCalls_cloned(&logger_conv);
23555         }
23556         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23557 }
23558
23559 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) {
23560         LDKChannelMonitor this_arg_conv;
23561         this_arg_conv.inner = (void*)(this_arg & (~1));
23562         this_arg_conv.is_owned = false;
23563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23564         unsigned char header_arr[80];
23565         CHECK(header->arr_len == 80);
23566         memcpy(header_arr, header->elems, 80); FREE(header);
23567         unsigned char (*header_ref)[80] = &header_arr;
23568         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23569         txdata_constr.datalen = txdata->arr_len;
23570         if (txdata_constr.datalen > 0)
23571                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23572         else
23573                 txdata_constr.data = NULL;
23574         uint32_t* txdata_vals = txdata->elems;
23575         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23576                 uint32_t txdata_conv_28 = txdata_vals[c];
23577                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23578                 CHECK_ACCESS(txdata_conv_28_ptr);
23579                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23580                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23581                 txdata_constr.data[c] = txdata_conv_28_conv;
23582         }
23583         FREE(txdata);
23584         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23585         CHECK_ACCESS(broadcaster_ptr);
23586         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23587         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23588                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23589                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23590         }
23591         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23592         CHECK_ACCESS(fee_estimator_ptr);
23593         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23594         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23595                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23596                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23597         }
23598         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23599         CHECK_ACCESS(logger_ptr);
23600         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23601         if (logger_conv.free == LDKLogger_JCalls_free) {
23602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23603                 LDKLogger_JCalls_cloned(&logger_conv);
23604         }
23605         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);
23606         uint32_tArray ret_arr = NULL;
23607         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23608         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23609         for (size_t n = 0; n < ret_var.datalen; n++) {
23610                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23611                 *ret_conv_39_conv = ret_var.data[n];
23612                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23613         }
23614         
23615         FREE(ret_var.data);
23616         return ret_arr;
23617 }
23618
23619 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) {
23620         LDKChannelMonitor this_arg_conv;
23621         this_arg_conv.inner = (void*)(this_arg & (~1));
23622         this_arg_conv.is_owned = false;
23623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23624         unsigned char txid_arr[32];
23625         CHECK(txid->arr_len == 32);
23626         memcpy(txid_arr, txid->elems, 32); FREE(txid);
23627         unsigned char (*txid_ref)[32] = &txid_arr;
23628         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23629         CHECK_ACCESS(broadcaster_ptr);
23630         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23631         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23632                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23633                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23634         }
23635         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23636         CHECK_ACCESS(fee_estimator_ptr);
23637         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23638         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23640                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23641         }
23642         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23643         CHECK_ACCESS(logger_ptr);
23644         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23645         if (logger_conv.free == LDKLogger_JCalls_free) {
23646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23647                 LDKLogger_JCalls_cloned(&logger_conv);
23648         }
23649         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
23650 }
23651
23652 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) {
23653         LDKChannelMonitor this_arg_conv;
23654         this_arg_conv.inner = (void*)(this_arg & (~1));
23655         this_arg_conv.is_owned = false;
23656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23657         unsigned char header_arr[80];
23658         CHECK(header->arr_len == 80);
23659         memcpy(header_arr, header->elems, 80); FREE(header);
23660         unsigned char (*header_ref)[80] = &header_arr;
23661         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23662         CHECK_ACCESS(broadcaster_ptr);
23663         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23664         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23665                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23666                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23667         }
23668         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23669         CHECK_ACCESS(fee_estimator_ptr);
23670         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23671         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23672                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23673                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23674         }
23675         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23676         CHECK_ACCESS(logger_ptr);
23677         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23678         if (logger_conv.free == LDKLogger_JCalls_free) {
23679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23680                 LDKLogger_JCalls_cloned(&logger_conv);
23681         }
23682         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23683         uint32_tArray ret_arr = NULL;
23684         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23685         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23686         for (size_t n = 0; n < ret_var.datalen; n++) {
23687                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23688                 *ret_conv_39_conv = ret_var.data[n];
23689                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23690         }
23691         
23692         FREE(ret_var.data);
23693         return ret_arr;
23694 }
23695
23696 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
23697         LDKChannelMonitor this_arg_conv;
23698         this_arg_conv.inner = (void*)(this_arg & (~1));
23699         this_arg_conv.is_owned = false;
23700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23701         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
23702         ptrArray ret_arr = NULL;
23703         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23704         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23705         for (size_t m = 0; m < ret_var.datalen; m++) {
23706                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
23707                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
23708                 ret_arr_ptr[m] = ret_conv_12_arr;
23709         }
23710         
23711         FREE(ret_var.data);
23712         return ret_arr;
23713 }
23714
23715 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
23716         LDKChannelMonitor this_arg_conv;
23717         this_arg_conv.inner = (void*)(this_arg & (~1));
23718         this_arg_conv.is_owned = false;
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23720         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
23721         uint32_t ret_ref = 0;
23722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23725         ret_ref = (uintptr_t)ret_var.inner;
23726         if (ret_var.is_owned) {
23727                 ret_ref |= 1;
23728         }
23729         return ret_ref;
23730 }
23731
23732 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
23733         LDKChannelMonitor this_arg_conv;
23734         this_arg_conv.inner = (void*)(this_arg & (~1));
23735         this_arg_conv.is_owned = false;
23736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23737         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
23738         uint32_tArray ret_arr = NULL;
23739         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23740         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23741         for (size_t j = 0; j < ret_var.datalen; j++) {
23742                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23743                 *ret_conv_9_copy = ret_var.data[j];
23744                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23745                 ret_arr_ptr[j] = ret_conv_9_ref;
23746         }
23747         
23748         FREE(ret_var.data);
23749         return ret_arr;
23750 }
23751
23752 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
23753         LDKu8slice ser_ref;
23754         ser_ref.datalen = ser->arr_len;
23755         ser_ref.data = ser->elems;
23756         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23757         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23758         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
23759         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23760         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
23761         FREE(ser);
23762         return (uint32_t)ret_conv;
23763 }
23764
23765 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
23766         LDKOutPoint this_obj_conv;
23767         this_obj_conv.inner = (void*)(this_obj & (~1));
23768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23770         OutPoint_free(this_obj_conv);
23771 }
23772
23773 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
23774         LDKOutPoint this_ptr_conv;
23775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23776         this_ptr_conv.is_owned = false;
23777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23778         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23779         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
23780         return ret_arr;
23781 }
23782
23783 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
23784         LDKOutPoint this_ptr_conv;
23785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23786         this_ptr_conv.is_owned = false;
23787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23788         LDKThirtyTwoBytes val_ref;
23789         CHECK(val->arr_len == 32);
23790         memcpy(val_ref.data, val->elems, 32); FREE(val);
23791         OutPoint_set_txid(&this_ptr_conv, val_ref);
23792 }
23793
23794 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
23795         LDKOutPoint this_ptr_conv;
23796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23797         this_ptr_conv.is_owned = false;
23798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23799         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
23800         return ret_conv;
23801 }
23802
23803 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
23804         LDKOutPoint this_ptr_conv;
23805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23806         this_ptr_conv.is_owned = false;
23807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23808         OutPoint_set_index(&this_ptr_conv, val);
23809 }
23810
23811 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
23812         LDKThirtyTwoBytes txid_arg_ref;
23813         CHECK(txid_arg->arr_len == 32);
23814         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
23815         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
23816         uint32_t ret_ref = 0;
23817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23820         ret_ref = (uintptr_t)ret_var.inner;
23821         if (ret_var.is_owned) {
23822                 ret_ref |= 1;
23823         }
23824         return ret_ref;
23825 }
23826
23827 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
23828         LDKOutPoint ret_var = OutPoint_clone(arg);
23829 uint32_t ret_ref = 0;
23830 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23831 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23832 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23833 ret_ref = (uintptr_t)ret_var.inner;
23834 if (ret_var.is_owned) {
23835         ret_ref |= 1;
23836 }
23837         return ret_ref;
23838 }
23839 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
23840         LDKOutPoint arg_conv;
23841         arg_conv.inner = (void*)(arg & (~1));
23842         arg_conv.is_owned = false;
23843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23844         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
23845         return ret_conv;
23846 }
23847
23848 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
23849         LDKOutPoint orig_conv;
23850         orig_conv.inner = (void*)(orig & (~1));
23851         orig_conv.is_owned = false;
23852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23853         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
23854         uint32_t ret_ref = 0;
23855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23858         ret_ref = (uintptr_t)ret_var.inner;
23859         if (ret_var.is_owned) {
23860                 ret_ref |= 1;
23861         }
23862         return ret_ref;
23863 }
23864
23865 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
23866         LDKOutPoint a_conv;
23867         a_conv.inner = (void*)(a & (~1));
23868         a_conv.is_owned = false;
23869         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23870         LDKOutPoint b_conv;
23871         b_conv.inner = (void*)(b & (~1));
23872         b_conv.is_owned = false;
23873         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23874         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
23875         return ret_conv;
23876 }
23877
23878 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
23879         LDKOutPoint o_conv;
23880         o_conv.inner = (void*)(o & (~1));
23881         o_conv.is_owned = false;
23882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23883         int64_t ret_conv = OutPoint_hash(&o_conv);
23884         return ret_conv;
23885 }
23886
23887 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
23888         LDKOutPoint this_arg_conv;
23889         this_arg_conv.inner = (void*)(this_arg & (~1));
23890         this_arg_conv.is_owned = false;
23891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23892         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23893         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
23894         return ret_arr;
23895 }
23896
23897 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
23898         LDKOutPoint obj_conv;
23899         obj_conv.inner = (void*)(obj & (~1));
23900         obj_conv.is_owned = false;
23901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23902         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
23903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23905         CVec_u8Z_free(ret_var);
23906         return ret_arr;
23907 }
23908
23909 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
23910         LDKu8slice ser_ref;
23911         ser_ref.datalen = ser->arr_len;
23912         ser_ref.data = ser->elems;
23913         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
23914         *ret_conv = OutPoint_read(ser_ref);
23915         FREE(ser);
23916         return (uint32_t)ret_conv;
23917 }
23918
23919 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
23920         LDKDelayedPaymentOutputDescriptor this_obj_conv;
23921         this_obj_conv.inner = (void*)(this_obj & (~1));
23922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23924         DelayedPaymentOutputDescriptor_free(this_obj_conv);
23925 }
23926
23927 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23928         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23930         this_ptr_conv.is_owned = false;
23931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23932         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23933         uint32_t ret_ref = 0;
23934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23937         ret_ref = (uintptr_t)ret_var.inner;
23938         if (ret_var.is_owned) {
23939                 ret_ref |= 1;
23940         }
23941         return ret_ref;
23942 }
23943
23944 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23945         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23947         this_ptr_conv.is_owned = false;
23948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23949         LDKOutPoint val_conv;
23950         val_conv.inner = (void*)(val & (~1));
23951         val_conv.is_owned = (val & 1) || (val == 0);
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23953         val_conv = OutPoint_clone(&val_conv);
23954         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23955 }
23956
23957 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
23958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23960         this_ptr_conv.is_owned = false;
23961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23962         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23963         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23964         return ret_arr;
23965 }
23966
23967 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23968         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23970         this_ptr_conv.is_owned = false;
23971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23972         LDKPublicKey val_ref;
23973         CHECK(val->arr_len == 33);
23974         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23975         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23976 }
23977
23978 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
23979         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23981         this_ptr_conv.is_owned = false;
23982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23983         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23984         return ret_conv;
23985 }
23986
23987 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23988         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23990         this_ptr_conv.is_owned = false;
23991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23992         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23993 }
23994
23995 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23996         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23998         this_ptr_conv.is_owned = false;
23999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24000         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24001         CHECK_ACCESS(val_ptr);
24002         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24003         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24004         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24005 }
24006
24007 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
24008         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24010         this_ptr_conv.is_owned = false;
24011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24012         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24013         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24014         return ret_arr;
24015 }
24016
24017 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
24018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24020         this_ptr_conv.is_owned = false;
24021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24022         LDKPublicKey val_ref;
24023         CHECK(val->arr_len == 33);
24024         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24025         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24026 }
24027
24028 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24029         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24031         this_ptr_conv.is_owned = false;
24032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24033         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24034         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24035         return ret_arr;
24036 }
24037
24038 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24039         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24041         this_ptr_conv.is_owned = false;
24042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24043         LDKThirtyTwoBytes val_ref;
24044         CHECK(val->arr_len == 32);
24045         memcpy(val_ref.data, val->elems, 32); FREE(val);
24046         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24047 }
24048
24049 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24050         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24052         this_ptr_conv.is_owned = false;
24053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24054         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24055         return ret_conv;
24056 }
24057
24058 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24059         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24061         this_ptr_conv.is_owned = false;
24062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24063         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24064 }
24065
24066 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) {
24067         LDKOutPoint outpoint_arg_conv;
24068         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24069         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24070         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24071         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24072         LDKPublicKey per_commitment_point_arg_ref;
24073         CHECK(per_commitment_point_arg->arr_len == 33);
24074         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24075         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24076         CHECK_ACCESS(output_arg_ptr);
24077         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24078         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24079         LDKPublicKey revocation_pubkey_arg_ref;
24080         CHECK(revocation_pubkey_arg->arr_len == 33);
24081         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24082         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24083         CHECK(channel_keys_id_arg->arr_len == 32);
24084         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24085         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);
24086         uint32_t ret_ref = 0;
24087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24090         ret_ref = (uintptr_t)ret_var.inner;
24091         if (ret_var.is_owned) {
24092                 ret_ref |= 1;
24093         }
24094         return ret_ref;
24095 }
24096
24097 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24098         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
24099 uint32_t ret_ref = 0;
24100 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24101 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24102 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24103 ret_ref = (uintptr_t)ret_var.inner;
24104 if (ret_var.is_owned) {
24105         ret_ref |= 1;
24106 }
24107         return ret_ref;
24108 }
24109 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24110         LDKDelayedPaymentOutputDescriptor arg_conv;
24111         arg_conv.inner = (void*)(arg & (~1));
24112         arg_conv.is_owned = false;
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24114         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24115         return ret_conv;
24116 }
24117
24118 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
24119         LDKDelayedPaymentOutputDescriptor orig_conv;
24120         orig_conv.inner = (void*)(orig & (~1));
24121         orig_conv.is_owned = false;
24122         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24123         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
24124         uint32_t ret_ref = 0;
24125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24128         ret_ref = (uintptr_t)ret_var.inner;
24129         if (ret_var.is_owned) {
24130                 ret_ref |= 1;
24131         }
24132         return ret_ref;
24133 }
24134
24135 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
24136         LDKDelayedPaymentOutputDescriptor obj_conv;
24137         obj_conv.inner = (void*)(obj & (~1));
24138         obj_conv.is_owned = false;
24139         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24140         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24141         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24142         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24143         CVec_u8Z_free(ret_var);
24144         return ret_arr;
24145 }
24146
24147 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24148         LDKu8slice ser_ref;
24149         ser_ref.datalen = ser->arr_len;
24150         ser_ref.data = ser->elems;
24151         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24152         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24153         FREE(ser);
24154         return (uint32_t)ret_conv;
24155 }
24156
24157 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
24158         LDKStaticPaymentOutputDescriptor this_obj_conv;
24159         this_obj_conv.inner = (void*)(this_obj & (~1));
24160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24162         StaticPaymentOutputDescriptor_free(this_obj_conv);
24163 }
24164
24165 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24166         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24168         this_ptr_conv.is_owned = false;
24169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24170         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24171         uint32_t ret_ref = 0;
24172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24175         ret_ref = (uintptr_t)ret_var.inner;
24176         if (ret_var.is_owned) {
24177                 ret_ref |= 1;
24178         }
24179         return ret_ref;
24180 }
24181
24182 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24183         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24185         this_ptr_conv.is_owned = false;
24186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24187         LDKOutPoint val_conv;
24188         val_conv.inner = (void*)(val & (~1));
24189         val_conv.is_owned = (val & 1) || (val == 0);
24190         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24191         val_conv = OutPoint_clone(&val_conv);
24192         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24193 }
24194
24195 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24196         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24198         this_ptr_conv.is_owned = false;
24199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24200         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24201         CHECK_ACCESS(val_ptr);
24202         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24203         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24204         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24205 }
24206
24207 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24208         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24210         this_ptr_conv.is_owned = false;
24211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24212         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24213         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24214         return ret_arr;
24215 }
24216
24217 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24218         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24220         this_ptr_conv.is_owned = false;
24221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24222         LDKThirtyTwoBytes val_ref;
24223         CHECK(val->arr_len == 32);
24224         memcpy(val_ref.data, val->elems, 32); FREE(val);
24225         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24226 }
24227
24228 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24229         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24231         this_ptr_conv.is_owned = false;
24232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24233         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24234         return ret_conv;
24235 }
24236
24237 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24238         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24240         this_ptr_conv.is_owned = false;
24241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24242         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24243 }
24244
24245 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) {
24246         LDKOutPoint outpoint_arg_conv;
24247         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24248         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24249         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24250         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24251         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24252         CHECK_ACCESS(output_arg_ptr);
24253         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24254         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24255         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24256         CHECK(channel_keys_id_arg->arr_len == 32);
24257         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24258         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24259         uint32_t ret_ref = 0;
24260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24263         ret_ref = (uintptr_t)ret_var.inner;
24264         if (ret_var.is_owned) {
24265                 ret_ref |= 1;
24266         }
24267         return ret_ref;
24268 }
24269
24270 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24271         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24272 uint32_t ret_ref = 0;
24273 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24274 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24275 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24276 ret_ref = (uintptr_t)ret_var.inner;
24277 if (ret_var.is_owned) {
24278         ret_ref |= 1;
24279 }
24280         return ret_ref;
24281 }
24282 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24283         LDKStaticPaymentOutputDescriptor arg_conv;
24284         arg_conv.inner = (void*)(arg & (~1));
24285         arg_conv.is_owned = false;
24286         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24287         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24288         return ret_conv;
24289 }
24290
24291 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
24292         LDKStaticPaymentOutputDescriptor orig_conv;
24293         orig_conv.inner = (void*)(orig & (~1));
24294         orig_conv.is_owned = false;
24295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24296         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24297         uint32_t ret_ref = 0;
24298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24301         ret_ref = (uintptr_t)ret_var.inner;
24302         if (ret_var.is_owned) {
24303                 ret_ref |= 1;
24304         }
24305         return ret_ref;
24306 }
24307
24308 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
24309         LDKStaticPaymentOutputDescriptor obj_conv;
24310         obj_conv.inner = (void*)(obj & (~1));
24311         obj_conv.is_owned = false;
24312         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24313         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24314         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24315         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24316         CVec_u8Z_free(ret_var);
24317         return ret_arr;
24318 }
24319
24320 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24321         LDKu8slice ser_ref;
24322         ser_ref.datalen = ser->arr_len;
24323         ser_ref.data = ser->elems;
24324         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24325         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24326         FREE(ser);
24327         return (uint32_t)ret_conv;
24328 }
24329
24330 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
24331         if ((this_ptr & 1) != 0) return;
24332         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24333         CHECK_ACCESS(this_ptr_ptr);
24334         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24335         FREE((void*)this_ptr);
24336         SpendableOutputDescriptor_free(this_ptr_conv);
24337 }
24338
24339 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
24340         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24341         *ret_copy = SpendableOutputDescriptor_clone(arg);
24342 uint32_t ret_ref = (uintptr_t)ret_copy;
24343         return ret_ref;
24344 }
24345 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
24346         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
24347         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
24348         return ret_conv;
24349 }
24350
24351 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
24352         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24353         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24354         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24355         uint32_t ret_ref = (uintptr_t)ret_copy;
24356         return ret_ref;
24357 }
24358
24359 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
24360         LDKOutPoint outpoint_conv;
24361         outpoint_conv.inner = (void*)(outpoint & (~1));
24362         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
24363         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
24364         outpoint_conv = OutPoint_clone(&outpoint_conv);
24365         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
24366         CHECK_ACCESS(output_ptr);
24367         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
24368         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
24369         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24370         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
24371         uint32_t ret_ref = (uintptr_t)ret_copy;
24372         return ret_ref;
24373 }
24374
24375 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
24376         LDKDelayedPaymentOutputDescriptor a_conv;
24377         a_conv.inner = (void*)(a & (~1));
24378         a_conv.is_owned = (a & 1) || (a == 0);
24379         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24380         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
24381         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24382         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
24383         uint32_t ret_ref = (uintptr_t)ret_copy;
24384         return ret_ref;
24385 }
24386
24387 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
24388         LDKStaticPaymentOutputDescriptor a_conv;
24389         a_conv.inner = (void*)(a & (~1));
24390         a_conv.is_owned = (a & 1) || (a == 0);
24391         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24392         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
24393         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24394         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
24395         uint32_t ret_ref = (uintptr_t)ret_copy;
24396         return ret_ref;
24397 }
24398
24399 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
24400         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
24401         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
24402         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24403         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24404         CVec_u8Z_free(ret_var);
24405         return ret_arr;
24406 }
24407
24408 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
24409         LDKu8slice ser_ref;
24410         ser_ref.datalen = ser->arr_len;
24411         ser_ref.data = ser->elems;
24412         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
24413         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
24414         FREE(ser);
24415         return (uint32_t)ret_conv;
24416 }
24417
24418 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
24419         if ((this_ptr & 1) != 0) return;
24420         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24421         CHECK_ACCESS(this_ptr_ptr);
24422         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
24423         FREE((void*)this_ptr);
24424         BaseSign_free(this_ptr_conv);
24425 }
24426
24427 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
24428         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24429         *ret_ret = Sign_clone(arg);
24430         return (uint32_t)ret_ret;
24431 }
24432 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
24433         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24434         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24435         LDKSign* arg_conv = (LDKSign*)arg_ptr;
24436         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
24437         return ret_conv;
24438 }
24439
24440 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
24441         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
24442         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
24443         LDKSign* orig_conv = (LDKSign*)orig_ptr;
24444         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24445         *ret_ret = Sign_clone(orig_conv);
24446         return (uint32_t)ret_ret;
24447 }
24448
24449 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
24450         if ((this_ptr & 1) != 0) return;
24451         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24452         CHECK_ACCESS(this_ptr_ptr);
24453         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
24454         FREE((void*)this_ptr);
24455         Sign_free(this_ptr_conv);
24456 }
24457
24458 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
24459         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
24460         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
24461         return ret_conv;
24462 }
24463
24464 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
24465         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
24466         return ret_conv;
24467 }
24468
24469 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
24470         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
24471         return ret_conv;
24472 }
24473
24474 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
24475         if ((this_ptr & 1) != 0) return;
24476         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24477         CHECK_ACCESS(this_ptr_ptr);
24478         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
24479         FREE((void*)this_ptr);
24480         KeysInterface_free(this_ptr_conv);
24481 }
24482
24483 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
24484         LDKInMemorySigner this_obj_conv;
24485         this_obj_conv.inner = (void*)(this_obj & (~1));
24486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24488         InMemorySigner_free(this_obj_conv);
24489 }
24490
24491 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
24492         LDKInMemorySigner this_ptr_conv;
24493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24494         this_ptr_conv.is_owned = false;
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24496         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24497         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
24498         return ret_arr;
24499 }
24500
24501 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
24502         LDKInMemorySigner this_ptr_conv;
24503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24504         this_ptr_conv.is_owned = false;
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24506         LDKSecretKey val_ref;
24507         CHECK(val->arr_len == 32);
24508         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24509         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
24510 }
24511
24512 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
24513         LDKInMemorySigner this_ptr_conv;
24514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24515         this_ptr_conv.is_owned = false;
24516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24517         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24518         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
24519         return ret_arr;
24520 }
24521
24522 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
24523         LDKInMemorySigner this_ptr_conv;
24524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24525         this_ptr_conv.is_owned = false;
24526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24527         LDKSecretKey val_ref;
24528         CHECK(val->arr_len == 32);
24529         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24530         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
24531 }
24532
24533 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
24534         LDKInMemorySigner this_ptr_conv;
24535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24536         this_ptr_conv.is_owned = false;
24537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24538         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24539         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
24540         return ret_arr;
24541 }
24542
24543 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
24544         LDKInMemorySigner this_ptr_conv;
24545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24546         this_ptr_conv.is_owned = false;
24547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24548         LDKSecretKey val_ref;
24549         CHECK(val->arr_len == 32);
24550         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24551         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
24552 }
24553
24554 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
24555         LDKInMemorySigner this_ptr_conv;
24556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24557         this_ptr_conv.is_owned = false;
24558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24559         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24560         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
24561         return ret_arr;
24562 }
24563
24564 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) {
24565         LDKInMemorySigner 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         LDKSecretKey val_ref;
24570         CHECK(val->arr_len == 32);
24571         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24572         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
24573 }
24574
24575 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
24576         LDKInMemorySigner this_ptr_conv;
24577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24578         this_ptr_conv.is_owned = false;
24579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24580         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24581         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
24582         return ret_arr;
24583 }
24584
24585 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
24586         LDKInMemorySigner this_ptr_conv;
24587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24588         this_ptr_conv.is_owned = false;
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24590         LDKSecretKey val_ref;
24591         CHECK(val->arr_len == 32);
24592         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24593         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
24594 }
24595
24596 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
24597         LDKInMemorySigner this_ptr_conv;
24598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24599         this_ptr_conv.is_owned = false;
24600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24601         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24602         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
24603         return ret_arr;
24604 }
24605
24606 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
24607         LDKInMemorySigner this_ptr_conv;
24608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24609         this_ptr_conv.is_owned = false;
24610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24611         LDKThirtyTwoBytes val_ref;
24612         CHECK(val->arr_len == 32);
24613         memcpy(val_ref.data, val->elems, 32); FREE(val);
24614         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
24615 }
24616
24617 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
24618         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
24619 uint32_t ret_ref = 0;
24620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24623 ret_ref = (uintptr_t)ret_var.inner;
24624 if (ret_var.is_owned) {
24625         ret_ref |= 1;
24626 }
24627         return ret_ref;
24628 }
24629 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
24630         LDKInMemorySigner arg_conv;
24631         arg_conv.inner = (void*)(arg & (~1));
24632         arg_conv.is_owned = false;
24633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24634         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
24635         return ret_conv;
24636 }
24637
24638 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
24639         LDKInMemorySigner orig_conv;
24640         orig_conv.inner = (void*)(orig & (~1));
24641         orig_conv.is_owned = false;
24642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24643         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
24644         uint32_t ret_ref = 0;
24645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24648         ret_ref = (uintptr_t)ret_var.inner;
24649         if (ret_var.is_owned) {
24650                 ret_ref |= 1;
24651         }
24652         return ret_ref;
24653 }
24654
24655 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) {
24656         LDKSecretKey node_secret_ref;
24657         CHECK(node_secret->arr_len == 32);
24658         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
24659         LDKSecretKey funding_key_ref;
24660         CHECK(funding_key->arr_len == 32);
24661         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
24662         LDKSecretKey revocation_base_key_ref;
24663         CHECK(revocation_base_key->arr_len == 32);
24664         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
24665         LDKSecretKey payment_key_ref;
24666         CHECK(payment_key->arr_len == 32);
24667         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
24668         LDKSecretKey delayed_payment_base_key_ref;
24669         CHECK(delayed_payment_base_key->arr_len == 32);
24670         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
24671         LDKSecretKey htlc_base_key_ref;
24672         CHECK(htlc_base_key->arr_len == 32);
24673         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
24674         LDKThirtyTwoBytes commitment_seed_ref;
24675         CHECK(commitment_seed->arr_len == 32);
24676         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
24677         LDKThirtyTwoBytes channel_keys_id_ref;
24678         CHECK(channel_keys_id->arr_len == 32);
24679         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
24680         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);
24681         uint32_t ret_ref = 0;
24682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24685         ret_ref = (uintptr_t)ret_var.inner;
24686         if (ret_var.is_owned) {
24687                 ret_ref |= 1;
24688         }
24689         return ret_ref;
24690 }
24691
24692 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
24693         LDKInMemorySigner this_arg_conv;
24694         this_arg_conv.inner = (void*)(this_arg & (~1));
24695         this_arg_conv.is_owned = false;
24696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24697         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
24698         uint32_t ret_ref = 0;
24699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24702         ret_ref = (uintptr_t)ret_var.inner;
24703         if (ret_var.is_owned) {
24704                 ret_ref |= 1;
24705         }
24706         return ret_ref;
24707 }
24708
24709 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
24710         LDKInMemorySigner this_arg_conv;
24711         this_arg_conv.inner = (void*)(this_arg & (~1));
24712         this_arg_conv.is_owned = false;
24713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24714         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
24715         return ret_conv;
24716 }
24717
24718 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
24719         LDKInMemorySigner this_arg_conv;
24720         this_arg_conv.inner = (void*)(this_arg & (~1));
24721         this_arg_conv.is_owned = false;
24722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24723         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
24724         return ret_conv;
24725 }
24726
24727 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
24728         LDKInMemorySigner this_arg_conv;
24729         this_arg_conv.inner = (void*)(this_arg & (~1));
24730         this_arg_conv.is_owned = false;
24731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24732         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
24733         return ret_conv;
24734 }
24735
24736 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
24737         LDKInMemorySigner this_arg_conv;
24738         this_arg_conv.inner = (void*)(this_arg & (~1));
24739         this_arg_conv.is_owned = false;
24740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24741         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
24742         uint32_t ret_ref = 0;
24743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24746         ret_ref = (uintptr_t)ret_var.inner;
24747         if (ret_var.is_owned) {
24748                 ret_ref |= 1;
24749         }
24750         return ret_ref;
24751 }
24752
24753 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
24754         LDKInMemorySigner this_arg_conv;
24755         this_arg_conv.inner = (void*)(this_arg & (~1));
24756         this_arg_conv.is_owned = false;
24757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24758         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
24759         uint32_t ret_ref = 0;
24760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24763         ret_ref = (uintptr_t)ret_var.inner;
24764         if (ret_var.is_owned) {
24765                 ret_ref |= 1;
24766         }
24767         return ret_ref;
24768 }
24769
24770 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
24771         LDKInMemorySigner this_arg_conv;
24772         this_arg_conv.inner = (void*)(this_arg & (~1));
24773         this_arg_conv.is_owned = false;
24774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24775         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
24776         return ret_conv;
24777 }
24778
24779 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) {
24780         LDKInMemorySigner this_arg_conv;
24781         this_arg_conv.inner = (void*)(this_arg & (~1));
24782         this_arg_conv.is_owned = false;
24783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24784         LDKTransaction spend_tx_ref;
24785         spend_tx_ref.datalen = spend_tx->arr_len;
24786         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24787         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24788         spend_tx_ref.data_is_owned = true;
24789         LDKStaticPaymentOutputDescriptor descriptor_conv;
24790         descriptor_conv.inner = (void*)(descriptor & (~1));
24791         descriptor_conv.is_owned = false;
24792         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24793         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24794         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24795         return (uint32_t)ret_conv;
24796 }
24797
24798 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) {
24799         LDKInMemorySigner this_arg_conv;
24800         this_arg_conv.inner = (void*)(this_arg & (~1));
24801         this_arg_conv.is_owned = false;
24802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24803         LDKTransaction spend_tx_ref;
24804         spend_tx_ref.datalen = spend_tx->arr_len;
24805         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24806         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24807         spend_tx_ref.data_is_owned = true;
24808         LDKDelayedPaymentOutputDescriptor descriptor_conv;
24809         descriptor_conv.inner = (void*)(descriptor & (~1));
24810         descriptor_conv.is_owned = false;
24811         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24812         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24813         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24814         return (uint32_t)ret_conv;
24815 }
24816
24817 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
24818         LDKInMemorySigner this_arg_conv;
24819         this_arg_conv.inner = (void*)(this_arg & (~1));
24820         this_arg_conv.is_owned = false;
24821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24822         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
24823         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
24824         return (uint32_t)ret_ret;
24825 }
24826
24827 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
24828         LDKInMemorySigner this_arg_conv;
24829         this_arg_conv.inner = (void*)(this_arg & (~1));
24830         this_arg_conv.is_owned = false;
24831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24832         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24833         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
24834         return (uint32_t)ret_ret;
24835 }
24836
24837 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
24838         LDKInMemorySigner obj_conv;
24839         obj_conv.inner = (void*)(obj & (~1));
24840         obj_conv.is_owned = false;
24841         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24842         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
24843         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24844         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24845         CVec_u8Z_free(ret_var);
24846         return ret_arr;
24847 }
24848
24849 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
24850         LDKu8slice ser_ref;
24851         ser_ref.datalen = ser->arr_len;
24852         ser_ref.data = ser->elems;
24853         LDKSecretKey arg_ref;
24854         CHECK(arg->arr_len == 32);
24855         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
24856         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
24857         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
24858         FREE(ser);
24859         return (uint32_t)ret_conv;
24860 }
24861
24862 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
24863         LDKKeysManager this_obj_conv;
24864         this_obj_conv.inner = (void*)(this_obj & (~1));
24865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24867         KeysManager_free(this_obj_conv);
24868 }
24869
24870 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
24871         unsigned char seed_arr[32];
24872         CHECK(seed->arr_len == 32);
24873         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24874         unsigned char (*seed_ref)[32] = &seed_arr;
24875         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
24876         uint32_t ret_ref = 0;
24877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24880         ret_ref = (uintptr_t)ret_var.inner;
24881         if (ret_var.is_owned) {
24882                 ret_ref |= 1;
24883         }
24884         return ret_ref;
24885 }
24886
24887 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) {
24888         LDKKeysManager this_arg_conv;
24889         this_arg_conv.inner = (void*)(this_arg & (~1));
24890         this_arg_conv.is_owned = false;
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24892         unsigned char params_arr[32];
24893         CHECK(params->arr_len == 32);
24894         memcpy(params_arr, params->elems, 32); FREE(params);
24895         unsigned char (*params_ref)[32] = &params_arr;
24896         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24897         uint32_t ret_ref = 0;
24898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24901         ret_ref = (uintptr_t)ret_var.inner;
24902         if (ret_var.is_owned) {
24903                 ret_ref |= 1;
24904         }
24905         return ret_ref;
24906 }
24907
24908 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) {
24909         LDKKeysManager this_arg_conv;
24910         this_arg_conv.inner = (void*)(this_arg & (~1));
24911         this_arg_conv.is_owned = false;
24912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24913         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24914         descriptors_constr.datalen = descriptors->arr_len;
24915         if (descriptors_constr.datalen > 0)
24916                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24917         else
24918                 descriptors_constr.data = NULL;
24919         uint32_t* descriptors_vals = descriptors->elems;
24920         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24921                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24922                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24923                 CHECK_ACCESS(descriptors_conv_27_ptr);
24924                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24925                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24926                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24927         }
24928         FREE(descriptors);
24929         LDKCVec_TxOutZ outputs_constr;
24930         outputs_constr.datalen = outputs->arr_len;
24931         if (outputs_constr.datalen > 0)
24932                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24933         else
24934                 outputs_constr.data = NULL;
24935         uint32_t* outputs_vals = outputs->elems;
24936         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24937                 uint32_t outputs_conv_7 = outputs_vals[h];
24938                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24939                 CHECK_ACCESS(outputs_conv_7_ptr);
24940                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24941                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24942                 outputs_constr.data[h] = outputs_conv_7_conv;
24943         }
24944         FREE(outputs);
24945         LDKCVec_u8Z change_destination_script_ref;
24946         change_destination_script_ref.datalen = change_destination_script->arr_len;
24947         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24948         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24949         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24950         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24951         return (uint32_t)ret_conv;
24952 }
24953
24954 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
24955         LDKKeysManager this_arg_conv;
24956         this_arg_conv.inner = (void*)(this_arg & (~1));
24957         this_arg_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24959         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24960         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
24961         return (uint32_t)ret_ret;
24962 }
24963
24964 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
24965         LDKPhantomKeysManager this_obj_conv;
24966         this_obj_conv.inner = (void*)(this_obj & (~1));
24967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24969         PhantomKeysManager_free(this_obj_conv);
24970 }
24971
24972 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
24973         LDKPhantomKeysManager this_arg_conv;
24974         this_arg_conv.inner = (void*)(this_arg & (~1));
24975         this_arg_conv.is_owned = false;
24976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24977         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24978         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
24979         return (uint32_t)ret_ret;
24980 }
24981
24982 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) {
24983         unsigned char seed_arr[32];
24984         CHECK(seed->arr_len == 32);
24985         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24986         unsigned char (*seed_ref)[32] = &seed_arr;
24987         unsigned char cross_node_seed_arr[32];
24988         CHECK(cross_node_seed->arr_len == 32);
24989         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
24990         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
24991         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
24992         uint32_t ret_ref = 0;
24993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24996         ret_ref = (uintptr_t)ret_var.inner;
24997         if (ret_var.is_owned) {
24998                 ret_ref |= 1;
24999         }
25000         return ret_ref;
25001 }
25002
25003 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) {
25004         LDKPhantomKeysManager this_arg_conv;
25005         this_arg_conv.inner = (void*)(this_arg & (~1));
25006         this_arg_conv.is_owned = false;
25007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25008         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25009         descriptors_constr.datalen = descriptors->arr_len;
25010         if (descriptors_constr.datalen > 0)
25011                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25012         else
25013                 descriptors_constr.data = NULL;
25014         uint32_t* descriptors_vals = descriptors->elems;
25015         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25016                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25017                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25018                 CHECK_ACCESS(descriptors_conv_27_ptr);
25019                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25020                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25021                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25022         }
25023         FREE(descriptors);
25024         LDKCVec_TxOutZ outputs_constr;
25025         outputs_constr.datalen = outputs->arr_len;
25026         if (outputs_constr.datalen > 0)
25027                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25028         else
25029                 outputs_constr.data = NULL;
25030         uint32_t* outputs_vals = outputs->elems;
25031         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25032                 uint32_t outputs_conv_7 = outputs_vals[h];
25033                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25034                 CHECK_ACCESS(outputs_conv_7_ptr);
25035                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25036                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25037                 outputs_constr.data[h] = outputs_conv_7_conv;
25038         }
25039         FREE(outputs);
25040         LDKCVec_u8Z change_destination_script_ref;
25041         change_destination_script_ref.datalen = change_destination_script->arr_len;
25042         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25043         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25044         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25045         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25046         return (uint32_t)ret_conv;
25047 }
25048
25049 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) {
25050         LDKPhantomKeysManager this_arg_conv;
25051         this_arg_conv.inner = (void*)(this_arg & (~1));
25052         this_arg_conv.is_owned = false;
25053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25054         unsigned char params_arr[32];
25055         CHECK(params->arr_len == 32);
25056         memcpy(params_arr, params->elems, 32); FREE(params);
25057         unsigned char (*params_ref)[32] = &params_arr;
25058         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25059         uint32_t ret_ref = 0;
25060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25063         ret_ref = (uintptr_t)ret_var.inner;
25064         if (ret_var.is_owned) {
25065                 ret_ref |= 1;
25066         }
25067         return ret_ref;
25068 }
25069
25070 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
25071         LDKChannelManager this_obj_conv;
25072         this_obj_conv.inner = (void*)(this_obj & (~1));
25073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25075         ChannelManager_free(this_obj_conv);
25076 }
25077
25078 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
25079         LDKChainParameters this_obj_conv;
25080         this_obj_conv.inner = (void*)(this_obj & (~1));
25081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25083         ChainParameters_free(this_obj_conv);
25084 }
25085
25086 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
25087         LDKChainParameters this_ptr_conv;
25088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25089         this_ptr_conv.is_owned = false;
25090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25091         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25092         return ret_conv;
25093 }
25094
25095 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
25096         LDKChainParameters this_ptr_conv;
25097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25098         this_ptr_conv.is_owned = false;
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25100         LDKNetwork val_conv = LDKNetwork_from_js(val);
25101         ChainParameters_set_network(&this_ptr_conv, val_conv);
25102 }
25103
25104 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
25105         LDKChainParameters this_ptr_conv;
25106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25107         this_ptr_conv.is_owned = false;
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25109         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25110         uint32_t ret_ref = 0;
25111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25114         ret_ref = (uintptr_t)ret_var.inner;
25115         if (ret_var.is_owned) {
25116                 ret_ref |= 1;
25117         }
25118         return ret_ref;
25119 }
25120
25121 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
25122         LDKChainParameters 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         LDKBestBlock val_conv;
25127         val_conv.inner = (void*)(val & (~1));
25128         val_conv.is_owned = (val & 1) || (val == 0);
25129         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25130         val_conv = BestBlock_clone(&val_conv);
25131         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25132 }
25133
25134 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
25135         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25136         LDKBestBlock best_block_arg_conv;
25137         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25138         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25139         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25140         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25141         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25142         uint32_t ret_ref = 0;
25143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25146         ret_ref = (uintptr_t)ret_var.inner;
25147         if (ret_var.is_owned) {
25148                 ret_ref |= 1;
25149         }
25150         return ret_ref;
25151 }
25152
25153 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25154         LDKChainParameters ret_var = ChainParameters_clone(arg);
25155 uint32_t ret_ref = 0;
25156 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25157 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25158 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25159 ret_ref = (uintptr_t)ret_var.inner;
25160 if (ret_var.is_owned) {
25161         ret_ref |= 1;
25162 }
25163         return ret_ref;
25164 }
25165 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
25166         LDKChainParameters arg_conv;
25167         arg_conv.inner = (void*)(arg & (~1));
25168         arg_conv.is_owned = false;
25169         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25170         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25171         return ret_conv;
25172 }
25173
25174 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
25175         LDKChainParameters orig_conv;
25176         orig_conv.inner = (void*)(orig & (~1));
25177         orig_conv.is_owned = false;
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25179         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25180         uint32_t ret_ref = 0;
25181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25184         ret_ref = (uintptr_t)ret_var.inner;
25185         if (ret_var.is_owned) {
25186                 ret_ref |= 1;
25187         }
25188         return ret_ref;
25189 }
25190
25191 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
25192         LDKCounterpartyForwardingInfo this_obj_conv;
25193         this_obj_conv.inner = (void*)(this_obj & (~1));
25194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25196         CounterpartyForwardingInfo_free(this_obj_conv);
25197 }
25198
25199 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
25200         LDKCounterpartyForwardingInfo this_ptr_conv;
25201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25202         this_ptr_conv.is_owned = false;
25203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25204         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25205         return ret_conv;
25206 }
25207
25208 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25209         LDKCounterpartyForwardingInfo this_ptr_conv;
25210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25211         this_ptr_conv.is_owned = false;
25212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25213         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25214 }
25215
25216 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
25217         LDKCounterpartyForwardingInfo 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         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25222         return ret_conv;
25223 }
25224
25225 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25226         LDKCounterpartyForwardingInfo this_ptr_conv;
25227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25228         this_ptr_conv.is_owned = false;
25229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25230         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25231 }
25232
25233 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
25234         LDKCounterpartyForwardingInfo this_ptr_conv;
25235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25236         this_ptr_conv.is_owned = false;
25237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25238         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25239         return ret_conv;
25240 }
25241
25242 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25243         LDKCounterpartyForwardingInfo this_ptr_conv;
25244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25245         this_ptr_conv.is_owned = false;
25246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25247         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25248 }
25249
25250 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) {
25251         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25252         uint32_t ret_ref = 0;
25253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25256         ret_ref = (uintptr_t)ret_var.inner;
25257         if (ret_var.is_owned) {
25258                 ret_ref |= 1;
25259         }
25260         return ret_ref;
25261 }
25262
25263 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25264         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25265 uint32_t ret_ref = 0;
25266 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25267 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25268 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25269 ret_ref = (uintptr_t)ret_var.inner;
25270 if (ret_var.is_owned) {
25271         ret_ref |= 1;
25272 }
25273         return ret_ref;
25274 }
25275 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
25276         LDKCounterpartyForwardingInfo arg_conv;
25277         arg_conv.inner = (void*)(arg & (~1));
25278         arg_conv.is_owned = false;
25279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25280         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25281         return ret_conv;
25282 }
25283
25284 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
25285         LDKCounterpartyForwardingInfo orig_conv;
25286         orig_conv.inner = (void*)(orig & (~1));
25287         orig_conv.is_owned = false;
25288         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25289         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25290         uint32_t ret_ref = 0;
25291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25294         ret_ref = (uintptr_t)ret_var.inner;
25295         if (ret_var.is_owned) {
25296                 ret_ref |= 1;
25297         }
25298         return ret_ref;
25299 }
25300
25301 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
25302         LDKChannelCounterparty this_obj_conv;
25303         this_obj_conv.inner = (void*)(this_obj & (~1));
25304         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25306         ChannelCounterparty_free(this_obj_conv);
25307 }
25308
25309 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
25310         LDKChannelCounterparty this_ptr_conv;
25311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25312         this_ptr_conv.is_owned = false;
25313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25315         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25316         return ret_arr;
25317 }
25318
25319 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
25320         LDKChannelCounterparty this_ptr_conv;
25321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25322         this_ptr_conv.is_owned = false;
25323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25324         LDKPublicKey val_ref;
25325         CHECK(val->arr_len == 33);
25326         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25327         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25328 }
25329
25330 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
25331         LDKChannelCounterparty this_ptr_conv;
25332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25333         this_ptr_conv.is_owned = false;
25334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25335         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25336         uint32_t ret_ref = 0;
25337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25340         ret_ref = (uintptr_t)ret_var.inner;
25341         if (ret_var.is_owned) {
25342                 ret_ref |= 1;
25343         }
25344         return ret_ref;
25345 }
25346
25347 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
25348         LDKChannelCounterparty this_ptr_conv;
25349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25350         this_ptr_conv.is_owned = false;
25351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25352         LDKInitFeatures val_conv;
25353         val_conv.inner = (void*)(val & (~1));
25354         val_conv.is_owned = (val & 1) || (val == 0);
25355         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25356         val_conv = InitFeatures_clone(&val_conv);
25357         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
25358 }
25359
25360 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25361         LDKChannelCounterparty this_ptr_conv;
25362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25363         this_ptr_conv.is_owned = false;
25364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25365         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
25366         return ret_conv;
25367 }
25368
25369 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
25370         LDKChannelCounterparty this_ptr_conv;
25371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25372         this_ptr_conv.is_owned = false;
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25374         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
25375 }
25376
25377 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
25378         LDKChannelCounterparty this_ptr_conv;
25379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25380         this_ptr_conv.is_owned = false;
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25382         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
25383         uint32_t ret_ref = 0;
25384         if ((uintptr_t)ret_var.inner > 4096) {
25385                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25386                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25388                 ret_ref = (uintptr_t)ret_var.inner;
25389                 if (ret_var.is_owned) {
25390                         ret_ref |= 1;
25391                 }
25392         }
25393         return ret_ref;
25394 }
25395
25396 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
25397         LDKChannelCounterparty this_ptr_conv;
25398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25399         this_ptr_conv.is_owned = false;
25400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25401         LDKCounterpartyForwardingInfo val_conv;
25402         val_conv.inner = (void*)(val & (~1));
25403         val_conv.is_owned = (val & 1) || (val == 0);
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25405         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
25406         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
25407 }
25408
25409 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
25410         LDKChannelCounterparty this_ptr_conv;
25411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25412         this_ptr_conv.is_owned = false;
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25414         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25415         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
25416         uint32_t ret_ref = (uintptr_t)ret_copy;
25417         return ret_ref;
25418 }
25419
25420 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) {
25421         LDKChannelCounterparty this_ptr_conv;
25422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25423         this_ptr_conv.is_owned = false;
25424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25425         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25426         CHECK_ACCESS(val_ptr);
25427         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25428         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25429         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25430 }
25431
25432 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
25433         LDKChannelCounterparty this_ptr_conv;
25434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25435         this_ptr_conv.is_owned = false;
25436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25437         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25438         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
25439         uint32_t ret_ref = (uintptr_t)ret_copy;
25440         return ret_ref;
25441 }
25442
25443 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) {
25444         LDKChannelCounterparty this_ptr_conv;
25445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25446         this_ptr_conv.is_owned = false;
25447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25448         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25449         CHECK_ACCESS(val_ptr);
25450         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25451         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25452         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
25453 }
25454
25455 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) {
25456         LDKPublicKey node_id_arg_ref;
25457         CHECK(node_id_arg->arr_len == 33);
25458         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
25459         LDKInitFeatures features_arg_conv;
25460         features_arg_conv.inner = (void*)(features_arg & (~1));
25461         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25462         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25463         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25464         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
25465         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
25466         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
25468         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
25469         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
25470         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
25471         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
25472         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
25473         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
25474         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
25475         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
25476         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
25477         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);
25478         uint32_t ret_ref = 0;
25479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25482         ret_ref = (uintptr_t)ret_var.inner;
25483         if (ret_var.is_owned) {
25484                 ret_ref |= 1;
25485         }
25486         return ret_ref;
25487 }
25488
25489 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
25490         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
25491 uint32_t ret_ref = 0;
25492 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25493 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25494 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25495 ret_ref = (uintptr_t)ret_var.inner;
25496 if (ret_var.is_owned) {
25497         ret_ref |= 1;
25498 }
25499         return ret_ref;
25500 }
25501 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
25502         LDKChannelCounterparty arg_conv;
25503         arg_conv.inner = (void*)(arg & (~1));
25504         arg_conv.is_owned = false;
25505         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25506         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
25507         return ret_conv;
25508 }
25509
25510 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
25511         LDKChannelCounterparty orig_conv;
25512         orig_conv.inner = (void*)(orig & (~1));
25513         orig_conv.is_owned = false;
25514         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25515         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
25516         uint32_t ret_ref = 0;
25517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25520         ret_ref = (uintptr_t)ret_var.inner;
25521         if (ret_var.is_owned) {
25522                 ret_ref |= 1;
25523         }
25524         return ret_ref;
25525 }
25526
25527 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
25528         LDKChannelDetails this_obj_conv;
25529         this_obj_conv.inner = (void*)(this_obj & (~1));
25530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25532         ChannelDetails_free(this_obj_conv);
25533 }
25534
25535 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
25536         LDKChannelDetails this_ptr_conv;
25537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25538         this_ptr_conv.is_owned = false;
25539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25540         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25541         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
25542         return ret_arr;
25543 }
25544
25545 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25546         LDKChannelDetails this_ptr_conv;
25547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25548         this_ptr_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25550         LDKThirtyTwoBytes val_ref;
25551         CHECK(val->arr_len == 32);
25552         memcpy(val_ref.data, val->elems, 32); FREE(val);
25553         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
25554 }
25555
25556 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
25557         LDKChannelDetails this_ptr_conv;
25558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25559         this_ptr_conv.is_owned = false;
25560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25561         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
25562         uint32_t ret_ref = 0;
25563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25566         ret_ref = (uintptr_t)ret_var.inner;
25567         if (ret_var.is_owned) {
25568                 ret_ref |= 1;
25569         }
25570         return ret_ref;
25571 }
25572
25573 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
25574         LDKChannelDetails this_ptr_conv;
25575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25576         this_ptr_conv.is_owned = false;
25577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25578         LDKChannelCounterparty val_conv;
25579         val_conv.inner = (void*)(val & (~1));
25580         val_conv.is_owned = (val & 1) || (val == 0);
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25582         val_conv = ChannelCounterparty_clone(&val_conv);
25583         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
25584 }
25585
25586 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
25587         LDKChannelDetails this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
25592         uint32_t ret_ref = 0;
25593         if ((uintptr_t)ret_var.inner > 4096) {
25594                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25595                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25597                 ret_ref = (uintptr_t)ret_var.inner;
25598                 if (ret_var.is_owned) {
25599                         ret_ref |= 1;
25600                 }
25601         }
25602         return ret_ref;
25603 }
25604
25605 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
25606         LDKChannelDetails this_ptr_conv;
25607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25608         this_ptr_conv.is_owned = false;
25609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25610         LDKOutPoint val_conv;
25611         val_conv.inner = (void*)(val & (~1));
25612         val_conv.is_owned = (val & 1) || (val == 0);
25613         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25614         val_conv = OutPoint_clone(&val_conv);
25615         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
25616 }
25617
25618 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
25619         LDKChannelDetails this_ptr_conv;
25620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25621         this_ptr_conv.is_owned = false;
25622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25623         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
25624         uint32_t ret_ref = 0;
25625         if ((uintptr_t)ret_var.inner > 4096) {
25626                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25627                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25629                 ret_ref = (uintptr_t)ret_var.inner;
25630                 if (ret_var.is_owned) {
25631                         ret_ref |= 1;
25632                 }
25633         }
25634         return ret_ref;
25635 }
25636
25637 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
25638         LDKChannelDetails this_ptr_conv;
25639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25640         this_ptr_conv.is_owned = false;
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25642         LDKChannelTypeFeatures val_conv;
25643         val_conv.inner = (void*)(val & (~1));
25644         val_conv.is_owned = (val & 1) || (val == 0);
25645         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25646         val_conv = ChannelTypeFeatures_clone(&val_conv);
25647         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
25648 }
25649
25650 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
25651         LDKChannelDetails this_ptr_conv;
25652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25653         this_ptr_conv.is_owned = false;
25654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25655         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25656         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
25657         uint32_t ret_ref = (uintptr_t)ret_copy;
25658         return ret_ref;
25659 }
25660
25661 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
25662         LDKChannelDetails this_ptr_conv;
25663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25664         this_ptr_conv.is_owned = false;
25665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25666         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25667         CHECK_ACCESS(val_ptr);
25668         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25669         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25670         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
25671 }
25672
25673 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
25674         LDKChannelDetails this_ptr_conv;
25675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25676         this_ptr_conv.is_owned = false;
25677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25678         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25679         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
25680         uint32_t ret_ref = (uintptr_t)ret_copy;
25681         return ret_ref;
25682 }
25683
25684 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25685         LDKChannelDetails this_ptr_conv;
25686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25687         this_ptr_conv.is_owned = false;
25688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25689         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25690         CHECK_ACCESS(val_ptr);
25691         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25692         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25693         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
25694 }
25695
25696 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
25697         LDKChannelDetails this_ptr_conv;
25698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25699         this_ptr_conv.is_owned = false;
25700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25701         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25702         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
25703         uint32_t ret_ref = (uintptr_t)ret_copy;
25704         return ret_ref;
25705 }
25706
25707 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25708         LDKChannelDetails this_ptr_conv;
25709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25710         this_ptr_conv.is_owned = false;
25711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25712         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25713         CHECK_ACCESS(val_ptr);
25714         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25715         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25716         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
25717 }
25718
25719 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
25720         LDKChannelDetails this_ptr_conv;
25721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25722         this_ptr_conv.is_owned = false;
25723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25724         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
25725         return ret_conv;
25726 }
25727
25728 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
25729         LDKChannelDetails this_ptr_conv;
25730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25731         this_ptr_conv.is_owned = false;
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25733         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
25734 }
25735
25736 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25737         LDKChannelDetails this_ptr_conv;
25738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25739         this_ptr_conv.is_owned = false;
25740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25741         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25742         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
25743         uint32_t ret_ref = (uintptr_t)ret_copy;
25744         return ret_ref;
25745 }
25746
25747 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
25748         LDKChannelDetails this_ptr_conv;
25749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25750         this_ptr_conv.is_owned = false;
25751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25752         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25753         CHECK_ACCESS(val_ptr);
25754         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25755         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25756         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
25757 }
25758
25759 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
25760         LDKChannelDetails this_ptr_conv;
25761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25762         this_ptr_conv.is_owned = false;
25763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25764         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
25765         return ret_conv;
25766 }
25767
25768 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
25769         LDKChannelDetails this_ptr_conv;
25770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25771         this_ptr_conv.is_owned = false;
25772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25773         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
25774 }
25775
25776 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
25777         LDKChannelDetails this_ptr_conv;
25778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25779         this_ptr_conv.is_owned = false;
25780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25781         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
25782         return ret_conv;
25783 }
25784
25785 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
25786         LDKChannelDetails this_ptr_conv;
25787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25788         this_ptr_conv.is_owned = false;
25789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25790         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
25791 }
25792
25793 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
25794         LDKChannelDetails this_ptr_conv;
25795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25796         this_ptr_conv.is_owned = false;
25797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25798         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
25799         return ret_conv;
25800 }
25801
25802 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25803         LDKChannelDetails this_ptr_conv;
25804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25805         this_ptr_conv.is_owned = false;
25806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25807         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
25808 }
25809
25810 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) {
25811         LDKChannelDetails this_ptr_conv;
25812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25813         this_ptr_conv.is_owned = false;
25814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25815         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
25816         return ret_conv;
25817 }
25818
25819 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) {
25820         LDKChannelDetails 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         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
25825 }
25826
25827 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
25828         LDKChannelDetails this_ptr_conv;
25829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25830         this_ptr_conv.is_owned = false;
25831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25832         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
25833         return ret_conv;
25834 }
25835
25836 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25837         LDKChannelDetails 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         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
25842 }
25843
25844 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
25845         LDKChannelDetails this_ptr_conv;
25846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25847         this_ptr_conv.is_owned = false;
25848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25849         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
25850         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
25851         uint32_t ret_ref = (uintptr_t)ret_copy;
25852         return ret_ref;
25853 }
25854
25855 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
25856         LDKChannelDetails this_ptr_conv;
25857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25858         this_ptr_conv.is_owned = false;
25859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25860         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25861         CHECK_ACCESS(val_ptr);
25862         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
25863         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
25864         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
25865 }
25866
25867 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
25868         LDKChannelDetails this_ptr_conv;
25869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25870         this_ptr_conv.is_owned = false;
25871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25872         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
25873         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
25874         uint32_t ret_ref = (uintptr_t)ret_copy;
25875         return ret_ref;
25876 }
25877
25878 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) {
25879         LDKChannelDetails this_ptr_conv;
25880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25881         this_ptr_conv.is_owned = false;
25882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25883         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25884         CHECK_ACCESS(val_ptr);
25885         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
25886         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
25887         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
25888 }
25889
25890 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
25891         LDKChannelDetails this_ptr_conv;
25892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25893         this_ptr_conv.is_owned = false;
25894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25895         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
25896         return ret_conv;
25897 }
25898
25899 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
25900         LDKChannelDetails this_ptr_conv;
25901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25902         this_ptr_conv.is_owned = false;
25903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25904         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
25905 }
25906
25907 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
25908         LDKChannelDetails this_ptr_conv;
25909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25910         this_ptr_conv.is_owned = false;
25911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25912         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
25913         return ret_conv;
25914 }
25915
25916 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
25917         LDKChannelDetails this_ptr_conv;
25918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25919         this_ptr_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25921         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
25922 }
25923
25924 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
25925         LDKChannelDetails this_ptr_conv;
25926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25927         this_ptr_conv.is_owned = false;
25928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25929         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
25930         return ret_conv;
25931 }
25932
25933 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
25934         LDKChannelDetails this_ptr_conv;
25935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25936         this_ptr_conv.is_owned = false;
25937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25938         ChannelDetails_set_is_usable(&this_ptr_conv, val);
25939 }
25940
25941 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
25942         LDKChannelDetails this_ptr_conv;
25943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25944         this_ptr_conv.is_owned = false;
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25946         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
25947         return ret_conv;
25948 }
25949
25950 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
25951         LDKChannelDetails 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         ChannelDetails_set_is_public(&this_ptr_conv, val);
25956 }
25957
25958 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
25959         LDKChannelDetails this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25963         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25964         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
25965         uint32_t ret_ref = (uintptr_t)ret_copy;
25966         return ret_ref;
25967 }
25968
25969 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) {
25970         LDKChannelDetails this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25975         CHECK_ACCESS(val_ptr);
25976         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25977         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25978         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25979 }
25980
25981 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
25982         LDKChannelDetails this_ptr_conv;
25983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25984         this_ptr_conv.is_owned = false;
25985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25986         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25987         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
25988         uint32_t ret_ref = (uintptr_t)ret_copy;
25989         return ret_ref;
25990 }
25991
25992 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) {
25993         LDKChannelDetails this_ptr_conv;
25994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25995         this_ptr_conv.is_owned = false;
25996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25997         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25998         CHECK_ACCESS(val_ptr);
25999         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26000         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26001         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26002 }
26003
26004 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint32_t this_ptr) {
26005         LDKChannelDetails this_ptr_conv;
26006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26007         this_ptr_conv.is_owned = false;
26008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26009         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26010         uint32_t ret_ref = 0;
26011         if ((uintptr_t)ret_var.inner > 4096) {
26012                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26013                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26015                 ret_ref = (uintptr_t)ret_var.inner;
26016                 if (ret_var.is_owned) {
26017                         ret_ref |= 1;
26018                 }
26019         }
26020         return ret_ref;
26021 }
26022
26023 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint32_t this_ptr, uint32_t val) {
26024         LDKChannelDetails this_ptr_conv;
26025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26026         this_ptr_conv.is_owned = false;
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26028         LDKChannelConfig val_conv;
26029         val_conv.inner = (void*)(val & (~1));
26030         val_conv.is_owned = (val & 1) || (val == 0);
26031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26032         val_conv = ChannelConfig_clone(&val_conv);
26033         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26034 }
26035
26036 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) {
26037         LDKThirtyTwoBytes channel_id_arg_ref;
26038         CHECK(channel_id_arg->arr_len == 32);
26039         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26040         LDKChannelCounterparty counterparty_arg_conv;
26041         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26042         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26043         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26044         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26045         LDKOutPoint funding_txo_arg_conv;
26046         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26047         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26048         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26049         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26050         LDKChannelTypeFeatures channel_type_arg_conv;
26051         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
26052         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26054         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26055         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26056         CHECK_ACCESS(short_channel_id_arg_ptr);
26057         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26058         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26059         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
26060         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26061         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26062         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
26063         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
26064         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26065         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26066         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
26067         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26068         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26069         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26070         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26071         CHECK_ACCESS(confirmations_required_arg_ptr);
26072         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26073         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26074         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26075         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26076         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26077         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26078         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
26079         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26080         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26081         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
26082         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
26083         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26084         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26085         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
26086         LDKChannelConfig config_arg_conv;
26087         config_arg_conv.inner = (void*)(config_arg & (~1));
26088         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26090         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26091         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);
26092         uint32_t ret_ref = 0;
26093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26096         ret_ref = (uintptr_t)ret_var.inner;
26097         if (ret_var.is_owned) {
26098                 ret_ref |= 1;
26099         }
26100         return ret_ref;
26101 }
26102
26103 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26104         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26105 uint32_t ret_ref = 0;
26106 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26107 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26108 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26109 ret_ref = (uintptr_t)ret_var.inner;
26110 if (ret_var.is_owned) {
26111         ret_ref |= 1;
26112 }
26113         return ret_ref;
26114 }
26115 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
26116         LDKChannelDetails arg_conv;
26117         arg_conv.inner = (void*)(arg & (~1));
26118         arg_conv.is_owned = false;
26119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26120         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26121         return ret_conv;
26122 }
26123
26124 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
26125         LDKChannelDetails orig_conv;
26126         orig_conv.inner = (void*)(orig & (~1));
26127         orig_conv.is_owned = false;
26128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26129         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26130         uint32_t ret_ref = 0;
26131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26134         ret_ref = (uintptr_t)ret_var.inner;
26135         if (ret_var.is_owned) {
26136                 ret_ref |= 1;
26137         }
26138         return ret_ref;
26139 }
26140
26141 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
26142         LDKChannelDetails this_arg_conv;
26143         this_arg_conv.inner = (void*)(this_arg & (~1));
26144         this_arg_conv.is_owned = false;
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26146         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26147         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26148         uint32_t ret_ref = (uintptr_t)ret_copy;
26149         return ret_ref;
26150 }
26151
26152 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
26153         LDKChannelDetails this_arg_conv;
26154         this_arg_conv.inner = (void*)(this_arg & (~1));
26155         this_arg_conv.is_owned = false;
26156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26157         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26158         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26159         uint32_t ret_ref = (uintptr_t)ret_copy;
26160         return ret_ref;
26161 }
26162
26163 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
26164         if ((this_ptr & 1) != 0) return;
26165         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26166         CHECK_ACCESS(this_ptr_ptr);
26167         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26168         FREE((void*)this_ptr);
26169         PaymentSendFailure_free(this_ptr_conv);
26170 }
26171
26172 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26173         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26174         *ret_copy = PaymentSendFailure_clone(arg);
26175 uint32_t ret_ref = (uintptr_t)ret_copy;
26176         return ret_ref;
26177 }
26178 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
26179         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26180         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26181         return ret_conv;
26182 }
26183
26184 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
26185         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26186         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26187         *ret_copy = PaymentSendFailure_clone(orig_conv);
26188         uint32_t ret_ref = (uintptr_t)ret_copy;
26189         return ret_ref;
26190 }
26191
26192 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
26193         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26194         CHECK_ACCESS(a_ptr);
26195         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26196         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26197         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26198         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26199         uint32_t ret_ref = (uintptr_t)ret_copy;
26200         return ret_ref;
26201 }
26202
26203 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
26204         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26205         a_constr.datalen = a->arr_len;
26206         if (a_constr.datalen > 0)
26207                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26208         else
26209                 a_constr.data = NULL;
26210         uint32_t* a_vals = a->elems;
26211         for (size_t w = 0; w < a_constr.datalen; w++) {
26212                 uint32_t a_conv_22 = a_vals[w];
26213                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26214                 CHECK_ACCESS(a_conv_22_ptr);
26215                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26216                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26217                 a_constr.data[w] = a_conv_22_conv;
26218         }
26219         FREE(a);
26220         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26221         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26222         uint32_t ret_ref = (uintptr_t)ret_copy;
26223         return ret_ref;
26224 }
26225
26226 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
26227         LDKCVec_APIErrorZ a_constr;
26228         a_constr.datalen = a->arr_len;
26229         if (a_constr.datalen > 0)
26230                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26231         else
26232                 a_constr.data = NULL;
26233         uint32_t* a_vals = a->elems;
26234         for (size_t k = 0; k < a_constr.datalen; k++) {
26235                 uint32_t a_conv_10 = a_vals[k];
26236                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26237                 CHECK_ACCESS(a_conv_10_ptr);
26238                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26239                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26240                 a_constr.data[k] = a_conv_10_conv;
26241         }
26242         FREE(a);
26243         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26244         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26245         uint32_t ret_ref = (uintptr_t)ret_copy;
26246         return ret_ref;
26247 }
26248
26249 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) {
26250         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26251         results_constr.datalen = results->arr_len;
26252         if (results_constr.datalen > 0)
26253                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26254         else
26255                 results_constr.data = NULL;
26256         uint32_t* results_vals = results->elems;
26257         for (size_t w = 0; w < results_constr.datalen; w++) {
26258                 uint32_t results_conv_22 = results_vals[w];
26259                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26260                 CHECK_ACCESS(results_conv_22_ptr);
26261                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26262                 results_constr.data[w] = results_conv_22_conv;
26263         }
26264         FREE(results);
26265         LDKRouteParameters failed_paths_retry_conv;
26266         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26267         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26268         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26269         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26270         LDKThirtyTwoBytes payment_id_ref;
26271         CHECK(payment_id->arr_len == 32);
26272         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26273         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26274         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26275         uint32_t ret_ref = (uintptr_t)ret_copy;
26276         return ret_ref;
26277 }
26278
26279 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
26280         LDKPhantomRouteHints this_obj_conv;
26281         this_obj_conv.inner = (void*)(this_obj & (~1));
26282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26284         PhantomRouteHints_free(this_obj_conv);
26285 }
26286
26287 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
26288         LDKPhantomRouteHints this_ptr_conv;
26289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26290         this_ptr_conv.is_owned = false;
26291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26292         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26293         uint32_tArray ret_arr = NULL;
26294         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26295         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26296         for (size_t q = 0; q < ret_var.datalen; q++) {
26297                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26298                 uint32_t ret_conv_16_ref = 0;
26299                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26300                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26302                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26303                 if (ret_conv_16_var.is_owned) {
26304                         ret_conv_16_ref |= 1;
26305                 }
26306                 ret_arr_ptr[q] = ret_conv_16_ref;
26307         }
26308         
26309         FREE(ret_var.data);
26310         return ret_arr;
26311 }
26312
26313 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
26314         LDKPhantomRouteHints this_ptr_conv;
26315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26316         this_ptr_conv.is_owned = false;
26317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26318         LDKCVec_ChannelDetailsZ val_constr;
26319         val_constr.datalen = val->arr_len;
26320         if (val_constr.datalen > 0)
26321                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26322         else
26323                 val_constr.data = NULL;
26324         uint32_t* val_vals = val->elems;
26325         for (size_t q = 0; q < val_constr.datalen; q++) {
26326                 uint32_t val_conv_16 = val_vals[q];
26327                 LDKChannelDetails val_conv_16_conv;
26328                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26329                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26330                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26331                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26332                 val_constr.data[q] = val_conv_16_conv;
26333         }
26334         FREE(val);
26335         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26336 }
26337
26338 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
26339         LDKPhantomRouteHints this_ptr_conv;
26340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26341         this_ptr_conv.is_owned = false;
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26344         return ret_conv;
26345 }
26346
26347 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
26348         LDKPhantomRouteHints this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26353 }
26354
26355 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
26356         LDKPhantomRouteHints this_ptr_conv;
26357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26358         this_ptr_conv.is_owned = false;
26359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26360         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26361         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
26362         return ret_arr;
26363 }
26364
26365 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
26366         LDKPhantomRouteHints this_ptr_conv;
26367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26368         this_ptr_conv.is_owned = false;
26369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26370         LDKPublicKey val_ref;
26371         CHECK(val->arr_len == 33);
26372         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26373         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
26374 }
26375
26376 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) {
26377         LDKCVec_ChannelDetailsZ channels_arg_constr;
26378         channels_arg_constr.datalen = channels_arg->arr_len;
26379         if (channels_arg_constr.datalen > 0)
26380                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26381         else
26382                 channels_arg_constr.data = NULL;
26383         uint32_t* channels_arg_vals = channels_arg->elems;
26384         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
26385                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
26386                 LDKChannelDetails channels_arg_conv_16_conv;
26387                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
26388                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
26389                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
26390                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
26391                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
26392         }
26393         FREE(channels_arg);
26394         LDKPublicKey real_node_pubkey_arg_ref;
26395         CHECK(real_node_pubkey_arg->arr_len == 33);
26396         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
26397         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
26398         uint32_t ret_ref = 0;
26399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26402         ret_ref = (uintptr_t)ret_var.inner;
26403         if (ret_var.is_owned) {
26404                 ret_ref |= 1;
26405         }
26406         return ret_ref;
26407 }
26408
26409 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
26410         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
26411 uint32_t ret_ref = 0;
26412 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26413 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26414 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26415 ret_ref = (uintptr_t)ret_var.inner;
26416 if (ret_var.is_owned) {
26417         ret_ref |= 1;
26418 }
26419         return ret_ref;
26420 }
26421 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
26422         LDKPhantomRouteHints arg_conv;
26423         arg_conv.inner = (void*)(arg & (~1));
26424         arg_conv.is_owned = false;
26425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26426         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
26427         return ret_conv;
26428 }
26429
26430 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
26431         LDKPhantomRouteHints orig_conv;
26432         orig_conv.inner = (void*)(orig & (~1));
26433         orig_conv.is_owned = false;
26434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26435         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
26436         uint32_t ret_ref = 0;
26437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26440         ret_ref = (uintptr_t)ret_var.inner;
26441         if (ret_var.is_owned) {
26442                 ret_ref |= 1;
26443         }
26444         return ret_ref;
26445 }
26446
26447 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) {
26448         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
26449         CHECK_ACCESS(fee_est_ptr);
26450         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
26451         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
26452                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26453                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
26454         }
26455         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26456         CHECK_ACCESS(chain_monitor_ptr);
26457         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26458         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26459                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26460                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26461         }
26462         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26463         CHECK_ACCESS(tx_broadcaster_ptr);
26464         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26465         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26467                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26468         }
26469         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26470         CHECK_ACCESS(logger_ptr);
26471         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26472         if (logger_conv.free == LDKLogger_JCalls_free) {
26473                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26474                 LDKLogger_JCalls_cloned(&logger_conv);
26475         }
26476         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26477         CHECK_ACCESS(keys_manager_ptr);
26478         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26479         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26481                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26482         }
26483         LDKUserConfig config_conv;
26484         config_conv.inner = (void*)(config & (~1));
26485         config_conv.is_owned = (config & 1) || (config == 0);
26486         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26487         config_conv = UserConfig_clone(&config_conv);
26488         LDKChainParameters params_conv;
26489         params_conv.inner = (void*)(params & (~1));
26490         params_conv.is_owned = (params & 1) || (params == 0);
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
26492         params_conv = ChainParameters_clone(&params_conv);
26493         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
26494         uint32_t ret_ref = 0;
26495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26498         ret_ref = (uintptr_t)ret_var.inner;
26499         if (ret_var.is_owned) {
26500                 ret_ref |= 1;
26501         }
26502         return ret_ref;
26503 }
26504
26505 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
26506         LDKChannelManager this_arg_conv;
26507         this_arg_conv.inner = (void*)(this_arg & (~1));
26508         this_arg_conv.is_owned = false;
26509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26510         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
26511         uint32_t ret_ref = 0;
26512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26515         ret_ref = (uintptr_t)ret_var.inner;
26516         if (ret_var.is_owned) {
26517                 ret_ref |= 1;
26518         }
26519         return ret_ref;
26520 }
26521
26522 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) {
26523         LDKChannelManager this_arg_conv;
26524         this_arg_conv.inner = (void*)(this_arg & (~1));
26525         this_arg_conv.is_owned = false;
26526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26527         LDKPublicKey their_network_key_ref;
26528         CHECK(their_network_key->arr_len == 33);
26529         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
26530         LDKUserConfig override_config_conv;
26531         override_config_conv.inner = (void*)(override_config & (~1));
26532         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
26533         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
26534         override_config_conv = UserConfig_clone(&override_config_conv);
26535         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
26536         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
26537         return (uint32_t)ret_conv;
26538 }
26539
26540 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
26541         LDKChannelManager this_arg_conv;
26542         this_arg_conv.inner = (void*)(this_arg & (~1));
26543         this_arg_conv.is_owned = false;
26544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26545         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
26546         uint32_tArray ret_arr = NULL;
26547         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26548         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26549         for (size_t q = 0; q < ret_var.datalen; q++) {
26550                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26551                 uint32_t ret_conv_16_ref = 0;
26552                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26553                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26555                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26556                 if (ret_conv_16_var.is_owned) {
26557                         ret_conv_16_ref |= 1;
26558                 }
26559                 ret_arr_ptr[q] = ret_conv_16_ref;
26560         }
26561         
26562         FREE(ret_var.data);
26563         return ret_arr;
26564 }
26565
26566 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
26567         LDKChannelManager this_arg_conv;
26568         this_arg_conv.inner = (void*)(this_arg & (~1));
26569         this_arg_conv.is_owned = false;
26570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26571         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
26572         uint32_tArray ret_arr = NULL;
26573         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26574         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26575         for (size_t q = 0; q < ret_var.datalen; q++) {
26576                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26577                 uint32_t ret_conv_16_ref = 0;
26578                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26579                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26580                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26581                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26582                 if (ret_conv_16_var.is_owned) {
26583                         ret_conv_16_ref |= 1;
26584                 }
26585                 ret_arr_ptr[q] = ret_conv_16_ref;
26586         }
26587         
26588         FREE(ret_var.data);
26589         return ret_arr;
26590 }
26591
26592 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) {
26593         LDKChannelManager this_arg_conv;
26594         this_arg_conv.inner = (void*)(this_arg & (~1));
26595         this_arg_conv.is_owned = false;
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26597         unsigned char channel_id_arr[32];
26598         CHECK(channel_id->arr_len == 32);
26599         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26600         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26601         LDKPublicKey counterparty_node_id_ref;
26602         CHECK(counterparty_node_id->arr_len == 33);
26603         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26604         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26605         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26606         return (uint32_t)ret_conv;
26607 }
26608
26609 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) {
26610         LDKChannelManager this_arg_conv;
26611         this_arg_conv.inner = (void*)(this_arg & (~1));
26612         this_arg_conv.is_owned = false;
26613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26614         unsigned char channel_id_arr[32];
26615         CHECK(channel_id->arr_len == 32);
26616         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26617         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26618         LDKPublicKey counterparty_node_id_ref;
26619         CHECK(counterparty_node_id->arr_len == 33);
26620         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26621         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26622         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
26623         return (uint32_t)ret_conv;
26624 }
26625
26626 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) {
26627         LDKChannelManager this_arg_conv;
26628         this_arg_conv.inner = (void*)(this_arg & (~1));
26629         this_arg_conv.is_owned = false;
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26631         unsigned char channel_id_arr[32];
26632         CHECK(channel_id->arr_len == 32);
26633         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26634         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26635         LDKPublicKey counterparty_node_id_ref;
26636         CHECK(counterparty_node_id->arr_len == 33);
26637         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26638         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26639         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26640         return (uint32_t)ret_conv;
26641 }
26642
26643 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) {
26644         LDKChannelManager this_arg_conv;
26645         this_arg_conv.inner = (void*)(this_arg & (~1));
26646         this_arg_conv.is_owned = false;
26647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26648         unsigned char channel_id_arr[32];
26649         CHECK(channel_id->arr_len == 32);
26650         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26651         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26652         LDKPublicKey counterparty_node_id_ref;
26653         CHECK(counterparty_node_id->arr_len == 33);
26654         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26655         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26656         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26657         return (uint32_t)ret_conv;
26658 }
26659
26660 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) {
26661         LDKChannelManager this_arg_conv;
26662         this_arg_conv.inner = (void*)(this_arg & (~1));
26663         this_arg_conv.is_owned = false;
26664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26665         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
26666 }
26667
26668 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) {
26669         LDKChannelManager this_arg_conv;
26670         this_arg_conv.inner = (void*)(this_arg & (~1));
26671         this_arg_conv.is_owned = false;
26672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26673         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
26674 }
26675
26676 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) {
26677         LDKChannelManager this_arg_conv;
26678         this_arg_conv.inner = (void*)(this_arg & (~1));
26679         this_arg_conv.is_owned = false;
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26681         LDKRoute route_conv;
26682         route_conv.inner = (void*)(route & (~1));
26683         route_conv.is_owned = false;
26684         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26685         LDKThirtyTwoBytes payment_hash_ref;
26686         CHECK(payment_hash->arr_len == 32);
26687         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26688         LDKThirtyTwoBytes payment_secret_ref;
26689         CHECK(payment_secret->arr_len == 32);
26690         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26691         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
26692         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
26693         return (uint32_t)ret_conv;
26694 }
26695
26696 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
26697         LDKChannelManager this_arg_conv;
26698         this_arg_conv.inner = (void*)(this_arg & (~1));
26699         this_arg_conv.is_owned = false;
26700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26701         LDKRoute route_conv;
26702         route_conv.inner = (void*)(route & (~1));
26703         route_conv.is_owned = false;
26704         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26705         LDKThirtyTwoBytes payment_id_ref;
26706         CHECK(payment_id->arr_len == 32);
26707         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26708         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
26709         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
26710         return (uint32_t)ret_conv;
26711 }
26712
26713 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
26714         LDKChannelManager this_arg_conv;
26715         this_arg_conv.inner = (void*)(this_arg & (~1));
26716         this_arg_conv.is_owned = false;
26717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26718         LDKThirtyTwoBytes payment_id_ref;
26719         CHECK(payment_id->arr_len == 32);
26720         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26721         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
26722 }
26723
26724 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) {
26725         LDKChannelManager this_arg_conv;
26726         this_arg_conv.inner = (void*)(this_arg & (~1));
26727         this_arg_conv.is_owned = false;
26728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26729         LDKRoute route_conv;
26730         route_conv.inner = (void*)(route & (~1));
26731         route_conv.is_owned = false;
26732         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26733         LDKThirtyTwoBytes payment_preimage_ref;
26734         CHECK(payment_preimage->arr_len == 32);
26735         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26736         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
26737         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
26738         return (uint32_t)ret_conv;
26739 }
26740
26741 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) {
26742         LDKChannelManager this_arg_conv;
26743         this_arg_conv.inner = (void*)(this_arg & (~1));
26744         this_arg_conv.is_owned = false;
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26746         unsigned char temporary_channel_id_arr[32];
26747         CHECK(temporary_channel_id->arr_len == 32);
26748         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26749         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26750         LDKPublicKey counterparty_node_id_ref;
26751         CHECK(counterparty_node_id->arr_len == 33);
26752         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26753         LDKTransaction funding_transaction_ref;
26754         funding_transaction_ref.datalen = funding_transaction->arr_len;
26755         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
26756         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
26757         funding_transaction_ref.data_is_owned = true;
26758         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26759         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
26760         return (uint32_t)ret_conv;
26761 }
26762
26763 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) {
26764         LDKChannelManager this_arg_conv;
26765         this_arg_conv.inner = (void*)(this_arg & (~1));
26766         this_arg_conv.is_owned = false;
26767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26768         LDKThreeBytes rgb_ref;
26769         CHECK(rgb->arr_len == 3);
26770         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
26771         LDKThirtyTwoBytes alias_ref;
26772         CHECK(alias->arr_len == 32);
26773         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
26774         LDKCVec_NetAddressZ addresses_constr;
26775         addresses_constr.datalen = addresses->arr_len;
26776         if (addresses_constr.datalen > 0)
26777                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26778         else
26779                 addresses_constr.data = NULL;
26780         uint32_t* addresses_vals = addresses->elems;
26781         for (size_t m = 0; m < addresses_constr.datalen; m++) {
26782                 uint32_t addresses_conv_12 = addresses_vals[m];
26783                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
26784                 CHECK_ACCESS(addresses_conv_12_ptr);
26785                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
26786                 addresses_constr.data[m] = addresses_conv_12_conv;
26787         }
26788         FREE(addresses);
26789         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
26790 }
26791
26792 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) {
26793         LDKChannelManager this_arg_conv;
26794         this_arg_conv.inner = (void*)(this_arg & (~1));
26795         this_arg_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26797         LDKPublicKey counterparty_node_id_ref;
26798         CHECK(counterparty_node_id->arr_len == 33);
26799         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26800         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
26801         channel_ids_constr.datalen = channel_ids->arr_len;
26802         if (channel_ids_constr.datalen > 0)
26803                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
26804         else
26805                 channel_ids_constr.data = NULL;
26806         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
26807         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
26808                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
26809                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
26810                 CHECK(channel_ids_conv_12->arr_len == 32);
26811                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
26812                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
26813         }
26814         FREE(channel_ids);
26815         LDKChannelConfig config_conv;
26816         config_conv.inner = (void*)(config & (~1));
26817         config_conv.is_owned = false;
26818         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26819         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26820         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
26821         return (uint32_t)ret_conv;
26822 }
26823
26824 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
26825         LDKChannelManager this_arg_conv;
26826         this_arg_conv.inner = (void*)(this_arg & (~1));
26827         this_arg_conv.is_owned = false;
26828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26829         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
26830 }
26831
26832 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
26833         LDKChannelManager this_arg_conv;
26834         this_arg_conv.inner = (void*)(this_arg & (~1));
26835         this_arg_conv.is_owned = false;
26836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26837         ChannelManager_timer_tick_occurred(&this_arg_conv);
26838 }
26839
26840 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
26841         LDKChannelManager this_arg_conv;
26842         this_arg_conv.inner = (void*)(this_arg & (~1));
26843         this_arg_conv.is_owned = false;
26844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26845         unsigned char payment_hash_arr[32];
26846         CHECK(payment_hash->arr_len == 32);
26847         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
26848         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
26849         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
26850 }
26851
26852 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
26853         LDKChannelManager this_arg_conv;
26854         this_arg_conv.inner = (void*)(this_arg & (~1));
26855         this_arg_conv.is_owned = false;
26856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26857         LDKThirtyTwoBytes payment_preimage_ref;
26858         CHECK(payment_preimage->arr_len == 32);
26859         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26860         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
26861 }
26862
26863 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
26864         LDKChannelManager this_arg_conv;
26865         this_arg_conv.inner = (void*)(this_arg & (~1));
26866         this_arg_conv.is_owned = false;
26867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26868         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26869         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
26870         return ret_arr;
26871 }
26872
26873 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) {
26874         LDKChannelManager this_arg_conv;
26875         this_arg_conv.inner = (void*)(this_arg & (~1));
26876         this_arg_conv.is_owned = false;
26877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26878         unsigned char temporary_channel_id_arr[32];
26879         CHECK(temporary_channel_id->arr_len == 32);
26880         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26881         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26882         LDKPublicKey counterparty_node_id_ref;
26883         CHECK(counterparty_node_id->arr_len == 33);
26884         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26885         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26886         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26887         return (uint32_t)ret_conv;
26888 }
26889
26890 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) {
26891         LDKChannelManager this_arg_conv;
26892         this_arg_conv.inner = (void*)(this_arg & (~1));
26893         this_arg_conv.is_owned = false;
26894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26895         unsigned char temporary_channel_id_arr[32];
26896         CHECK(temporary_channel_id->arr_len == 32);
26897         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26898         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26899         LDKPublicKey counterparty_node_id_ref;
26900         CHECK(counterparty_node_id->arr_len == 33);
26901         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26902         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26903         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26904         return (uint32_t)ret_conv;
26905 }
26906
26907 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) {
26908         LDKChannelManager this_arg_conv;
26909         this_arg_conv.inner = (void*)(this_arg & (~1));
26910         this_arg_conv.is_owned = false;
26911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26912         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26913         CHECK_ACCESS(min_value_msat_ptr);
26914         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26915         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26916         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
26917         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26918         return (uint32_t)ret_conv;
26919 }
26920
26921 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) {
26922         LDKChannelManager this_arg_conv;
26923         this_arg_conv.inner = (void*)(this_arg & (~1));
26924         this_arg_conv.is_owned = false;
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26926         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26927         CHECK_ACCESS(min_value_msat_ptr);
26928         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26929         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26930         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
26931         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26932         return (uint32_t)ret_conv;
26933 }
26934
26935 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) {
26936         LDKChannelManager this_arg_conv;
26937         this_arg_conv.inner = (void*)(this_arg & (~1));
26938         this_arg_conv.is_owned = false;
26939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26940         LDKThirtyTwoBytes payment_hash_ref;
26941         CHECK(payment_hash->arr_len == 32);
26942         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26943         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26944         CHECK_ACCESS(min_value_msat_ptr);
26945         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26946         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26947         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
26948         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26949         return (uint32_t)ret_conv;
26950 }
26951
26952 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) {
26953         LDKChannelManager this_arg_conv;
26954         this_arg_conv.inner = (void*)(this_arg & (~1));
26955         this_arg_conv.is_owned = false;
26956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26957         LDKThirtyTwoBytes payment_hash_ref;
26958         CHECK(payment_hash->arr_len == 32);
26959         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26960         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26961         CHECK_ACCESS(min_value_msat_ptr);
26962         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26963         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26964         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
26965         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26966         return (uint32_t)ret_conv;
26967 }
26968
26969 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) {
26970         LDKChannelManager this_arg_conv;
26971         this_arg_conv.inner = (void*)(this_arg & (~1));
26972         this_arg_conv.is_owned = false;
26973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26974         LDKThirtyTwoBytes payment_hash_ref;
26975         CHECK(payment_hash->arr_len == 32);
26976         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26977         LDKThirtyTwoBytes payment_secret_ref;
26978         CHECK(payment_secret->arr_len == 32);
26979         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26980         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
26981         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
26982         return (uint32_t)ret_conv;
26983 }
26984
26985 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
26986         LDKChannelManager this_arg_conv;
26987         this_arg_conv.inner = (void*)(this_arg & (~1));
26988         this_arg_conv.is_owned = false;
26989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26990         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
26991         return ret_conv;
26992 }
26993
26994 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
26995         LDKChannelManager this_arg_conv;
26996         this_arg_conv.inner = (void*)(this_arg & (~1));
26997         this_arg_conv.is_owned = false;
26998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26999         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27000         uint32_t ret_ref = 0;
27001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27004         ret_ref = (uintptr_t)ret_var.inner;
27005         if (ret_var.is_owned) {
27006                 ret_ref |= 1;
27007         }
27008         return ret_ref;
27009 }
27010
27011 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
27012         LDKChannelManager this_arg_conv;
27013         this_arg_conv.inner = (void*)(this_arg & (~1));
27014         this_arg_conv.is_owned = false;
27015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27016         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27017         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27018         return (uint32_t)ret_ret;
27019 }
27020
27021 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
27022         LDKChannelManager this_arg_conv;
27023         this_arg_conv.inner = (void*)(this_arg & (~1));
27024         this_arg_conv.is_owned = false;
27025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27026         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27027         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27028         return (uint32_t)ret_ret;
27029 }
27030
27031 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
27032         LDKChannelManager this_arg_conv;
27033         this_arg_conv.inner = (void*)(this_arg & (~1));
27034         this_arg_conv.is_owned = false;
27035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27036         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27037         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27038         return (uint32_t)ret_ret;
27039 }
27040
27041 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
27042         LDKChannelManager this_arg_conv;
27043         this_arg_conv.inner = (void*)(this_arg & (~1));
27044         this_arg_conv.is_owned = false;
27045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27046         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27047         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27048         return (uint32_t)ret_ret;
27049 }
27050
27051 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
27052         LDKChannelManager this_arg_conv;
27053         this_arg_conv.inner = (void*)(this_arg & (~1));
27054         this_arg_conv.is_owned = false;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27056         ChannelManager_await_persistable_update(&this_arg_conv);
27057 }
27058
27059 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
27060         LDKChannelManager this_arg_conv;
27061         this_arg_conv.inner = (void*)(this_arg & (~1));
27062         this_arg_conv.is_owned = false;
27063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27064         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27065         uint32_t ret_ref = 0;
27066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27069         ret_ref = (uintptr_t)ret_var.inner;
27070         if (ret_var.is_owned) {
27071                 ret_ref |= 1;
27072         }
27073         return ret_ref;
27074 }
27075
27076 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
27077         LDKChannelManager this_arg_conv;
27078         this_arg_conv.inner = (void*)(this_arg & (~1));
27079         this_arg_conv.is_owned = false;
27080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27081         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27082         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27083         return (uint32_t)ret_ret;
27084 }
27085
27086 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
27087         LDKCounterpartyForwardingInfo obj_conv;
27088         obj_conv.inner = (void*)(obj & (~1));
27089         obj_conv.is_owned = false;
27090         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27091         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27092         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27093         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27094         CVec_u8Z_free(ret_var);
27095         return ret_arr;
27096 }
27097
27098 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27099         LDKu8slice ser_ref;
27100         ser_ref.datalen = ser->arr_len;
27101         ser_ref.data = ser->elems;
27102         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27103         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27104         FREE(ser);
27105         return (uint32_t)ret_conv;
27106 }
27107
27108 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
27109         LDKChannelCounterparty obj_conv;
27110         obj_conv.inner = (void*)(obj & (~1));
27111         obj_conv.is_owned = false;
27112         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27113         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27114         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27115         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27116         CVec_u8Z_free(ret_var);
27117         return ret_arr;
27118 }
27119
27120 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27121         LDKu8slice ser_ref;
27122         ser_ref.datalen = ser->arr_len;
27123         ser_ref.data = ser->elems;
27124         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27125         *ret_conv = ChannelCounterparty_read(ser_ref);
27126         FREE(ser);
27127         return (uint32_t)ret_conv;
27128 }
27129
27130 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
27131         LDKChannelDetails obj_conv;
27132         obj_conv.inner = (void*)(obj & (~1));
27133         obj_conv.is_owned = false;
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27135         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27136         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27137         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27138         CVec_u8Z_free(ret_var);
27139         return ret_arr;
27140 }
27141
27142 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27143         LDKu8slice ser_ref;
27144         ser_ref.datalen = ser->arr_len;
27145         ser_ref.data = ser->elems;
27146         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27147         *ret_conv = ChannelDetails_read(ser_ref);
27148         FREE(ser);
27149         return (uint32_t)ret_conv;
27150 }
27151
27152 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
27153         LDKPhantomRouteHints obj_conv;
27154         obj_conv.inner = (void*)(obj & (~1));
27155         obj_conv.is_owned = false;
27156         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27157         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27158         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27159         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27160         CVec_u8Z_free(ret_var);
27161         return ret_arr;
27162 }
27163
27164 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27165         LDKu8slice ser_ref;
27166         ser_ref.datalen = ser->arr_len;
27167         ser_ref.data = ser->elems;
27168         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27169         *ret_conv = PhantomRouteHints_read(ser_ref);
27170         FREE(ser);
27171         return (uint32_t)ret_conv;
27172 }
27173
27174 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
27175         LDKChannelManager obj_conv;
27176         obj_conv.inner = (void*)(obj & (~1));
27177         obj_conv.is_owned = false;
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27179         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27180         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27181         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27182         CVec_u8Z_free(ret_var);
27183         return ret_arr;
27184 }
27185
27186 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
27187         LDKChannelManagerReadArgs this_obj_conv;
27188         this_obj_conv.inner = (void*)(this_obj & (~1));
27189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27191         ChannelManagerReadArgs_free(this_obj_conv);
27192 }
27193
27194 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
27195         LDKChannelManagerReadArgs this_ptr_conv;
27196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27197         this_ptr_conv.is_owned = false;
27198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27199         // WARNING: This object doesn't live past this scope, needs clone!
27200         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27201         return ret_ret;
27202 }
27203
27204 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
27205         LDKChannelManagerReadArgs this_ptr_conv;
27206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27207         this_ptr_conv.is_owned = false;
27208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27209         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27210         CHECK_ACCESS(val_ptr);
27211         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27212         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27213                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27214                 LDKKeysInterface_JCalls_cloned(&val_conv);
27215         }
27216         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27217 }
27218
27219 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
27220         LDKChannelManagerReadArgs this_ptr_conv;
27221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27222         this_ptr_conv.is_owned = false;
27223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27224         // WARNING: This object doesn't live past this scope, needs clone!
27225         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27226         return ret_ret;
27227 }
27228
27229 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
27230         LDKChannelManagerReadArgs this_ptr_conv;
27231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27232         this_ptr_conv.is_owned = false;
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27234         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27235         CHECK_ACCESS(val_ptr);
27236         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27237         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27238                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27239                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27240         }
27241         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27242 }
27243
27244 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
27245         LDKChannelManagerReadArgs this_ptr_conv;
27246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27247         this_ptr_conv.is_owned = false;
27248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27249         // WARNING: This object doesn't live past this scope, needs clone!
27250         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27251         return ret_ret;
27252 }
27253
27254 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
27255         LDKChannelManagerReadArgs this_ptr_conv;
27256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27257         this_ptr_conv.is_owned = false;
27258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27259         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27260         CHECK_ACCESS(val_ptr);
27261         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27262         if (val_conv.free == LDKWatch_JCalls_free) {
27263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27264                 LDKWatch_JCalls_cloned(&val_conv);
27265         }
27266         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27267 }
27268
27269 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
27270         LDKChannelManagerReadArgs this_ptr_conv;
27271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27272         this_ptr_conv.is_owned = false;
27273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27274         // WARNING: This object doesn't live past this scope, needs clone!
27275         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27276         return ret_ret;
27277 }
27278
27279 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
27280         LDKChannelManagerReadArgs this_ptr_conv;
27281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27282         this_ptr_conv.is_owned = false;
27283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27284         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27285         CHECK_ACCESS(val_ptr);
27286         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27287         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27288                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27289                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27290         }
27291         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27292 }
27293
27294 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
27295         LDKChannelManagerReadArgs this_ptr_conv;
27296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27297         this_ptr_conv.is_owned = false;
27298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27299         // WARNING: This object doesn't live past this scope, needs clone!
27300         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27301         return ret_ret;
27302 }
27303
27304 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
27305         LDKChannelManagerReadArgs this_ptr_conv;
27306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27307         this_ptr_conv.is_owned = false;
27308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27309         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27310         CHECK_ACCESS(val_ptr);
27311         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27312         if (val_conv.free == LDKLogger_JCalls_free) {
27313                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27314                 LDKLogger_JCalls_cloned(&val_conv);
27315         }
27316         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27317 }
27318
27319 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
27320         LDKChannelManagerReadArgs this_ptr_conv;
27321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27322         this_ptr_conv.is_owned = false;
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27324         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27325         uint32_t ret_ref = 0;
27326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27329         ret_ref = (uintptr_t)ret_var.inner;
27330         if (ret_var.is_owned) {
27331                 ret_ref |= 1;
27332         }
27333         return ret_ref;
27334 }
27335
27336 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
27337         LDKChannelManagerReadArgs this_ptr_conv;
27338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27339         this_ptr_conv.is_owned = false;
27340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27341         LDKUserConfig val_conv;
27342         val_conv.inner = (void*)(val & (~1));
27343         val_conv.is_owned = (val & 1) || (val == 0);
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27345         val_conv = UserConfig_clone(&val_conv);
27346         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
27347 }
27348
27349 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) {
27350         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27351         CHECK_ACCESS(keys_manager_ptr);
27352         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27353         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27354                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27355                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27356         }
27357         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27358         CHECK_ACCESS(fee_estimator_ptr);
27359         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27360         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27361                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27362                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27363         }
27364         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27365         CHECK_ACCESS(chain_monitor_ptr);
27366         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27367         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27368                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27369                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27370         }
27371         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27372         CHECK_ACCESS(tx_broadcaster_ptr);
27373         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27374         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27375                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27376                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27377         }
27378         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27379         CHECK_ACCESS(logger_ptr);
27380         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27381         if (logger_conv.free == LDKLogger_JCalls_free) {
27382                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27383                 LDKLogger_JCalls_cloned(&logger_conv);
27384         }
27385         LDKUserConfig default_config_conv;
27386         default_config_conv.inner = (void*)(default_config & (~1));
27387         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
27389         default_config_conv = UserConfig_clone(&default_config_conv);
27390         LDKCVec_ChannelMonitorZ channel_monitors_constr;
27391         channel_monitors_constr.datalen = channel_monitors->arr_len;
27392         if (channel_monitors_constr.datalen > 0)
27393                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
27394         else
27395                 channel_monitors_constr.data = NULL;
27396         uint32_t* channel_monitors_vals = channel_monitors->elems;
27397         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
27398                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
27399                 LDKChannelMonitor channel_monitors_conv_16_conv;
27400                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
27401                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
27402                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
27403                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
27404         }
27405         FREE(channel_monitors);
27406         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);
27407         uint32_t ret_ref = 0;
27408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27411         ret_ref = (uintptr_t)ret_var.inner;
27412         if (ret_var.is_owned) {
27413                 ret_ref |= 1;
27414         }
27415         return ret_ref;
27416 }
27417
27418 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
27419         LDKu8slice ser_ref;
27420         ser_ref.datalen = ser->arr_len;
27421         ser_ref.data = ser->elems;
27422         LDKChannelManagerReadArgs arg_conv;
27423         arg_conv.inner = (void*)(arg & (~1));
27424         arg_conv.is_owned = (arg & 1) || (arg == 0);
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27426         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
27427         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
27428         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
27429         FREE(ser);
27430         return (uint32_t)ret_conv;
27431 }
27432
27433 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
27434         LDKExpandedKey this_obj_conv;
27435         this_obj_conv.inner = (void*)(this_obj & (~1));
27436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27438         ExpandedKey_free(this_obj_conv);
27439 }
27440
27441 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
27442         unsigned char key_material_arr[32];
27443         CHECK(key_material->arr_len == 32);
27444         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
27445         unsigned char (*key_material_ref)[32] = &key_material_arr;
27446         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
27447         uint32_t ret_ref = 0;
27448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27451         ret_ref = (uintptr_t)ret_var.inner;
27452         if (ret_var.is_owned) {
27453                 ret_ref |= 1;
27454         }
27455         return ret_ref;
27456 }
27457
27458 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) {
27459         LDKExpandedKey keys_conv;
27460         keys_conv.inner = (void*)(keys & (~1));
27461         keys_conv.is_owned = false;
27462         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
27463         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27464         CHECK_ACCESS(min_value_msat_ptr);
27465         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27466         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27467         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27468         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
27469         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
27470         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27471         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
27472         return (uint32_t)ret_conv;
27473 }
27474
27475 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) {
27476         LDKExpandedKey keys_conv;
27477         keys_conv.inner = (void*)(keys & (~1));
27478         keys_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
27480         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27481         CHECK_ACCESS(min_value_msat_ptr);
27482         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27483         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27484         LDKThirtyTwoBytes payment_hash_ref;
27485         CHECK(payment_hash->arr_len == 32);
27486         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27487         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27488         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
27489         return (uint32_t)ret_conv;
27490 }
27491
27492 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
27493         LDKDecodeError this_obj_conv;
27494         this_obj_conv.inner = (void*)(this_obj & (~1));
27495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27497         DecodeError_free(this_obj_conv);
27498 }
27499
27500 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
27501         LDKDecodeError ret_var = DecodeError_clone(arg);
27502 uint32_t ret_ref = 0;
27503 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27504 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27505 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27506 ret_ref = (uintptr_t)ret_var.inner;
27507 if (ret_var.is_owned) {
27508         ret_ref |= 1;
27509 }
27510         return ret_ref;
27511 }
27512 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
27513         LDKDecodeError arg_conv;
27514         arg_conv.inner = (void*)(arg & (~1));
27515         arg_conv.is_owned = false;
27516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27517         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
27518         return ret_conv;
27519 }
27520
27521 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
27522         LDKDecodeError orig_conv;
27523         orig_conv.inner = (void*)(orig & (~1));
27524         orig_conv.is_owned = false;
27525         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27526         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
27527         uint32_t ret_ref = 0;
27528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27531         ret_ref = (uintptr_t)ret_var.inner;
27532         if (ret_var.is_owned) {
27533                 ret_ref |= 1;
27534         }
27535         return ret_ref;
27536 }
27537
27538 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
27539         LDKInit this_obj_conv;
27540         this_obj_conv.inner = (void*)(this_obj & (~1));
27541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27543         Init_free(this_obj_conv);
27544 }
27545
27546 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
27547         LDKInit this_ptr_conv;
27548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27549         this_ptr_conv.is_owned = false;
27550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27551         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
27552         uint32_t ret_ref = 0;
27553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27556         ret_ref = (uintptr_t)ret_var.inner;
27557         if (ret_var.is_owned) {
27558                 ret_ref |= 1;
27559         }
27560         return ret_ref;
27561 }
27562
27563 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
27564         LDKInit this_ptr_conv;
27565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27566         this_ptr_conv.is_owned = false;
27567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27568         LDKInitFeatures val_conv;
27569         val_conv.inner = (void*)(val & (~1));
27570         val_conv.is_owned = (val & 1) || (val == 0);
27571         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27572         val_conv = InitFeatures_clone(&val_conv);
27573         Init_set_features(&this_ptr_conv, val_conv);
27574 }
27575
27576 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
27577         LDKInit this_ptr_conv;
27578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27579         this_ptr_conv.is_owned = false;
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27581         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
27582         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
27583         uint32_t ret_ref = (uintptr_t)ret_copy;
27584         return ret_ref;
27585 }
27586
27587 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
27588         LDKInit this_ptr_conv;
27589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27590         this_ptr_conv.is_owned = false;
27591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27592         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27593         CHECK_ACCESS(val_ptr);
27594         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
27595         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
27596         Init_set_remote_network_address(&this_ptr_conv, val_conv);
27597 }
27598
27599 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
27600         LDKInitFeatures features_arg_conv;
27601         features_arg_conv.inner = (void*)(features_arg & (~1));
27602         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27604         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27605         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
27606         CHECK_ACCESS(remote_network_address_arg_ptr);
27607         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
27608         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
27609         uint32_t ret_ref = 0;
27610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27613         ret_ref = (uintptr_t)ret_var.inner;
27614         if (ret_var.is_owned) {
27615                 ret_ref |= 1;
27616         }
27617         return ret_ref;
27618 }
27619
27620 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
27621         LDKInit ret_var = Init_clone(arg);
27622 uint32_t ret_ref = 0;
27623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27626 ret_ref = (uintptr_t)ret_var.inner;
27627 if (ret_var.is_owned) {
27628         ret_ref |= 1;
27629 }
27630         return ret_ref;
27631 }
27632 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
27633         LDKInit arg_conv;
27634         arg_conv.inner = (void*)(arg & (~1));
27635         arg_conv.is_owned = false;
27636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27637         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
27638         return ret_conv;
27639 }
27640
27641 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
27642         LDKInit orig_conv;
27643         orig_conv.inner = (void*)(orig & (~1));
27644         orig_conv.is_owned = false;
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27646         LDKInit ret_var = Init_clone(&orig_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 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
27659         LDKErrorMessage this_obj_conv;
27660         this_obj_conv.inner = (void*)(this_obj & (~1));
27661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27663         ErrorMessage_free(this_obj_conv);
27664 }
27665
27666 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
27667         LDKErrorMessage this_ptr_conv;
27668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27669         this_ptr_conv.is_owned = false;
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27671         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27672         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
27673         return ret_arr;
27674 }
27675
27676 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27677         LDKErrorMessage this_ptr_conv;
27678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27679         this_ptr_conv.is_owned = false;
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27681         LDKThirtyTwoBytes val_ref;
27682         CHECK(val->arr_len == 32);
27683         memcpy(val_ref.data, val->elems, 32); FREE(val);
27684         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
27685 }
27686
27687 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
27688         LDKErrorMessage this_ptr_conv;
27689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27690         this_ptr_conv.is_owned = false;
27691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27692         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
27693         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27694         Str_free(ret_str);
27695         return ret_conv;
27696 }
27697
27698 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
27699         LDKErrorMessage this_ptr_conv;
27700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27701         this_ptr_conv.is_owned = false;
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27703         LDKStr val_conv = str_ref_to_owned_c(val);
27704         ErrorMessage_set_data(&this_ptr_conv, val_conv);
27705 }
27706
27707 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27708         LDKThirtyTwoBytes channel_id_arg_ref;
27709         CHECK(channel_id_arg->arr_len == 32);
27710         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27711         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27712         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
27713         uint32_t ret_ref = 0;
27714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27717         ret_ref = (uintptr_t)ret_var.inner;
27718         if (ret_var.is_owned) {
27719                 ret_ref |= 1;
27720         }
27721         return ret_ref;
27722 }
27723
27724 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
27725         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
27726 uint32_t ret_ref = 0;
27727 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27728 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27730 ret_ref = (uintptr_t)ret_var.inner;
27731 if (ret_var.is_owned) {
27732         ret_ref |= 1;
27733 }
27734         return ret_ref;
27735 }
27736 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
27737         LDKErrorMessage arg_conv;
27738         arg_conv.inner = (void*)(arg & (~1));
27739         arg_conv.is_owned = false;
27740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27741         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
27742         return ret_conv;
27743 }
27744
27745 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
27746         LDKErrorMessage orig_conv;
27747         orig_conv.inner = (void*)(orig & (~1));
27748         orig_conv.is_owned = false;
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27750         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
27751         uint32_t ret_ref = 0;
27752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27755         ret_ref = (uintptr_t)ret_var.inner;
27756         if (ret_var.is_owned) {
27757                 ret_ref |= 1;
27758         }
27759         return ret_ref;
27760 }
27761
27762 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
27763         LDKWarningMessage this_obj_conv;
27764         this_obj_conv.inner = (void*)(this_obj & (~1));
27765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27767         WarningMessage_free(this_obj_conv);
27768 }
27769
27770 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
27771         LDKWarningMessage this_ptr_conv;
27772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27773         this_ptr_conv.is_owned = false;
27774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27775         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27776         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
27777         return ret_arr;
27778 }
27779
27780 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27781         LDKWarningMessage this_ptr_conv;
27782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27783         this_ptr_conv.is_owned = false;
27784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27785         LDKThirtyTwoBytes val_ref;
27786         CHECK(val->arr_len == 32);
27787         memcpy(val_ref.data, val->elems, 32); FREE(val);
27788         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
27789 }
27790
27791 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
27792         LDKWarningMessage this_ptr_conv;
27793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27794         this_ptr_conv.is_owned = false;
27795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27796         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
27797         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27798         Str_free(ret_str);
27799         return ret_conv;
27800 }
27801
27802 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
27803         LDKWarningMessage this_ptr_conv;
27804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27805         this_ptr_conv.is_owned = false;
27806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27807         LDKStr val_conv = str_ref_to_owned_c(val);
27808         WarningMessage_set_data(&this_ptr_conv, val_conv);
27809 }
27810
27811 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27812         LDKThirtyTwoBytes channel_id_arg_ref;
27813         CHECK(channel_id_arg->arr_len == 32);
27814         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27815         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27816         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
27817         uint32_t ret_ref = 0;
27818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27821         ret_ref = (uintptr_t)ret_var.inner;
27822         if (ret_var.is_owned) {
27823                 ret_ref |= 1;
27824         }
27825         return ret_ref;
27826 }
27827
27828 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
27829         LDKWarningMessage ret_var = WarningMessage_clone(arg);
27830 uint32_t ret_ref = 0;
27831 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27832 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27833 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27834 ret_ref = (uintptr_t)ret_var.inner;
27835 if (ret_var.is_owned) {
27836         ret_ref |= 1;
27837 }
27838         return ret_ref;
27839 }
27840 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
27841         LDKWarningMessage arg_conv;
27842         arg_conv.inner = (void*)(arg & (~1));
27843         arg_conv.is_owned = false;
27844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27845         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
27846         return ret_conv;
27847 }
27848
27849 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
27850         LDKWarningMessage orig_conv;
27851         orig_conv.inner = (void*)(orig & (~1));
27852         orig_conv.is_owned = false;
27853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27854         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
27855         uint32_t ret_ref = 0;
27856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27859         ret_ref = (uintptr_t)ret_var.inner;
27860         if (ret_var.is_owned) {
27861                 ret_ref |= 1;
27862         }
27863         return ret_ref;
27864 }
27865
27866 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
27867         LDKPing this_obj_conv;
27868         this_obj_conv.inner = (void*)(this_obj & (~1));
27869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27871         Ping_free(this_obj_conv);
27872 }
27873
27874 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
27875         LDKPing this_ptr_conv;
27876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27877         this_ptr_conv.is_owned = false;
27878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27879         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
27880         return ret_conv;
27881 }
27882
27883 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
27884         LDKPing this_ptr_conv;
27885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27886         this_ptr_conv.is_owned = false;
27887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27888         Ping_set_ponglen(&this_ptr_conv, val);
27889 }
27890
27891 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
27892         LDKPing 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         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
27897         return ret_conv;
27898 }
27899
27900 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
27901         LDKPing this_ptr_conv;
27902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27903         this_ptr_conv.is_owned = false;
27904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27905         Ping_set_byteslen(&this_ptr_conv, val);
27906 }
27907
27908 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
27909         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
27910         uint32_t ret_ref = 0;
27911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27914         ret_ref = (uintptr_t)ret_var.inner;
27915         if (ret_var.is_owned) {
27916                 ret_ref |= 1;
27917         }
27918         return ret_ref;
27919 }
27920
27921 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
27922         LDKPing ret_var = Ping_clone(arg);
27923 uint32_t ret_ref = 0;
27924 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27925 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27926 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27927 ret_ref = (uintptr_t)ret_var.inner;
27928 if (ret_var.is_owned) {
27929         ret_ref |= 1;
27930 }
27931         return ret_ref;
27932 }
27933 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
27934         LDKPing arg_conv;
27935         arg_conv.inner = (void*)(arg & (~1));
27936         arg_conv.is_owned = false;
27937         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27938         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
27939         return ret_conv;
27940 }
27941
27942 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
27943         LDKPing orig_conv;
27944         orig_conv.inner = (void*)(orig & (~1));
27945         orig_conv.is_owned = false;
27946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27947         LDKPing ret_var = Ping_clone(&orig_conv);
27948         uint32_t ret_ref = 0;
27949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27952         ret_ref = (uintptr_t)ret_var.inner;
27953         if (ret_var.is_owned) {
27954                 ret_ref |= 1;
27955         }
27956         return ret_ref;
27957 }
27958
27959 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
27960         LDKPong this_obj_conv;
27961         this_obj_conv.inner = (void*)(this_obj & (~1));
27962         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27964         Pong_free(this_obj_conv);
27965 }
27966
27967 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
27968         LDKPong this_ptr_conv;
27969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27970         this_ptr_conv.is_owned = false;
27971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27972         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
27973         return ret_conv;
27974 }
27975
27976 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
27977         LDKPong this_ptr_conv;
27978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27979         this_ptr_conv.is_owned = false;
27980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27981         Pong_set_byteslen(&this_ptr_conv, val);
27982 }
27983
27984 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
27985         LDKPong ret_var = Pong_new(byteslen_arg);
27986         uint32_t ret_ref = 0;
27987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27990         ret_ref = (uintptr_t)ret_var.inner;
27991         if (ret_var.is_owned) {
27992                 ret_ref |= 1;
27993         }
27994         return ret_ref;
27995 }
27996
27997 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
27998         LDKPong ret_var = Pong_clone(arg);
27999 uint32_t ret_ref = 0;
28000 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28001 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28002 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28003 ret_ref = (uintptr_t)ret_var.inner;
28004 if (ret_var.is_owned) {
28005         ret_ref |= 1;
28006 }
28007         return ret_ref;
28008 }
28009 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
28010         LDKPong arg_conv;
28011         arg_conv.inner = (void*)(arg & (~1));
28012         arg_conv.is_owned = false;
28013         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28014         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
28015         return ret_conv;
28016 }
28017
28018 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
28019         LDKPong orig_conv;
28020         orig_conv.inner = (void*)(orig & (~1));
28021         orig_conv.is_owned = false;
28022         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28023         LDKPong ret_var = Pong_clone(&orig_conv);
28024         uint32_t ret_ref = 0;
28025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28028         ret_ref = (uintptr_t)ret_var.inner;
28029         if (ret_var.is_owned) {
28030                 ret_ref |= 1;
28031         }
28032         return ret_ref;
28033 }
28034
28035 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
28036         LDKOpenChannel this_obj_conv;
28037         this_obj_conv.inner = (void*)(this_obj & (~1));
28038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28040         OpenChannel_free(this_obj_conv);
28041 }
28042
28043 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
28044         LDKOpenChannel this_ptr_conv;
28045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28046         this_ptr_conv.is_owned = false;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28048         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28049         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28050         return ret_arr;
28051 }
28052
28053 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
28054         LDKOpenChannel this_ptr_conv;
28055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28056         this_ptr_conv.is_owned = false;
28057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28058         LDKThirtyTwoBytes val_ref;
28059         CHECK(val->arr_len == 32);
28060         memcpy(val_ref.data, val->elems, 32); FREE(val);
28061         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28062 }
28063
28064 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
28065         LDKOpenChannel this_ptr_conv;
28066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28067         this_ptr_conv.is_owned = false;
28068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28069         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28070         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28071         return ret_arr;
28072 }
28073
28074 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28075         LDKOpenChannel this_ptr_conv;
28076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28077         this_ptr_conv.is_owned = false;
28078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28079         LDKThirtyTwoBytes val_ref;
28080         CHECK(val->arr_len == 32);
28081         memcpy(val_ref.data, val->elems, 32); FREE(val);
28082         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28083 }
28084
28085 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
28086         LDKOpenChannel this_ptr_conv;
28087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28088         this_ptr_conv.is_owned = false;
28089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28090         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28091         return ret_conv;
28092 }
28093
28094 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
28095         LDKOpenChannel this_ptr_conv;
28096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28097         this_ptr_conv.is_owned = false;
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28099         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28100 }
28101
28102 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
28103         LDKOpenChannel this_ptr_conv;
28104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28105         this_ptr_conv.is_owned = false;
28106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28107         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28108         return ret_conv;
28109 }
28110
28111 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
28112         LDKOpenChannel this_ptr_conv;
28113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28114         this_ptr_conv.is_owned = false;
28115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28116         OpenChannel_set_push_msat(&this_ptr_conv, val);
28117 }
28118
28119 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28120         LDKOpenChannel this_ptr_conv;
28121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28122         this_ptr_conv.is_owned = false;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28124         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28125         return ret_conv;
28126 }
28127
28128 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28129         LDKOpenChannel this_ptr_conv;
28130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28131         this_ptr_conv.is_owned = false;
28132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28133         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28134 }
28135
28136 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) {
28137         LDKOpenChannel this_ptr_conv;
28138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28139         this_ptr_conv.is_owned = false;
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28141         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28142         return ret_conv;
28143 }
28144
28145 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) {
28146         LDKOpenChannel this_ptr_conv;
28147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28148         this_ptr_conv.is_owned = false;
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28150         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28151 }
28152
28153 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28154         LDKOpenChannel this_ptr_conv;
28155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28156         this_ptr_conv.is_owned = false;
28157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28158         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28159         return ret_conv;
28160 }
28161
28162 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28163         LDKOpenChannel this_ptr_conv;
28164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28165         this_ptr_conv.is_owned = false;
28166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28167         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28168 }
28169
28170 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28171         LDKOpenChannel this_ptr_conv;
28172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28173         this_ptr_conv.is_owned = false;
28174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28175         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28176         return ret_conv;
28177 }
28178
28179 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28180         LDKOpenChannel this_ptr_conv;
28181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28182         this_ptr_conv.is_owned = false;
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28184         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28185 }
28186
28187 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
28188         LDKOpenChannel this_ptr_conv;
28189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28190         this_ptr_conv.is_owned = false;
28191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28192         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28193         return ret_conv;
28194 }
28195
28196 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28197         LDKOpenChannel this_ptr_conv;
28198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28199         this_ptr_conv.is_owned = false;
28200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28201         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28202 }
28203
28204 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
28205         LDKOpenChannel this_ptr_conv;
28206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28207         this_ptr_conv.is_owned = false;
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28209         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28210         return ret_conv;
28211 }
28212
28213 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28214         LDKOpenChannel this_ptr_conv;
28215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28216         this_ptr_conv.is_owned = false;
28217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28218         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28219 }
28220
28221 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28222         LDKOpenChannel this_ptr_conv;
28223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28224         this_ptr_conv.is_owned = false;
28225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28226         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28227         return ret_conv;
28228 }
28229
28230 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28231         LDKOpenChannel this_ptr_conv;
28232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28233         this_ptr_conv.is_owned = false;
28234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28235         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28236 }
28237
28238 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
28239         LDKOpenChannel this_ptr_conv;
28240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28241         this_ptr_conv.is_owned = false;
28242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28243         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28244         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28245         return ret_arr;
28246 }
28247
28248 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28249         LDKOpenChannel this_ptr_conv;
28250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28251         this_ptr_conv.is_owned = false;
28252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28253         LDKPublicKey val_ref;
28254         CHECK(val->arr_len == 33);
28255         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28256         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28257 }
28258
28259 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
28260         LDKOpenChannel this_ptr_conv;
28261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28262         this_ptr_conv.is_owned = false;
28263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28264         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28265         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28266         return ret_arr;
28267 }
28268
28269 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28270         LDKOpenChannel this_ptr_conv;
28271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28272         this_ptr_conv.is_owned = false;
28273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28274         LDKPublicKey val_ref;
28275         CHECK(val->arr_len == 33);
28276         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28277         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28278 }
28279
28280 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
28281         LDKOpenChannel this_ptr_conv;
28282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28283         this_ptr_conv.is_owned = false;
28284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28285         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28286         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28287         return ret_arr;
28288 }
28289
28290 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28291         LDKOpenChannel this_ptr_conv;
28292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28293         this_ptr_conv.is_owned = false;
28294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28295         LDKPublicKey val_ref;
28296         CHECK(val->arr_len == 33);
28297         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28298         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28299 }
28300
28301 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28302         LDKOpenChannel this_ptr_conv;
28303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28304         this_ptr_conv.is_owned = false;
28305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28306         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28307         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28308         return ret_arr;
28309 }
28310
28311 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28312         LDKOpenChannel this_ptr_conv;
28313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28314         this_ptr_conv.is_owned = false;
28315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28316         LDKPublicKey val_ref;
28317         CHECK(val->arr_len == 33);
28318         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28319         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28320 }
28321
28322 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
28323         LDKOpenChannel this_ptr_conv;
28324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28325         this_ptr_conv.is_owned = false;
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28327         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28328         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28329         return ret_arr;
28330 }
28331
28332 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28333         LDKOpenChannel this_ptr_conv;
28334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28335         this_ptr_conv.is_owned = false;
28336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28337         LDKPublicKey val_ref;
28338         CHECK(val->arr_len == 33);
28339         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28340         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28341 }
28342
28343 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28344         LDKOpenChannel this_ptr_conv;
28345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28346         this_ptr_conv.is_owned = false;
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28348         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28349         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28350         return ret_arr;
28351 }
28352
28353 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) {
28354         LDKOpenChannel this_ptr_conv;
28355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28356         this_ptr_conv.is_owned = false;
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28358         LDKPublicKey val_ref;
28359         CHECK(val->arr_len == 33);
28360         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28361         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28362 }
28363
28364 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
28365         LDKOpenChannel this_ptr_conv;
28366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28367         this_ptr_conv.is_owned = false;
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28369         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
28370         return ret_conv;
28371 }
28372
28373 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
28374         LDKOpenChannel this_ptr_conv;
28375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28376         this_ptr_conv.is_owned = false;
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28378         OpenChannel_set_channel_flags(&this_ptr_conv, val);
28379 }
28380
28381 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
28382         LDKOpenChannel this_ptr_conv;
28383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28384         this_ptr_conv.is_owned = false;
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28386         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
28387         uint32_t ret_ref = 0;
28388         if ((uintptr_t)ret_var.inner > 4096) {
28389                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28390                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28392                 ret_ref = (uintptr_t)ret_var.inner;
28393                 if (ret_var.is_owned) {
28394                         ret_ref |= 1;
28395                 }
28396         }
28397         return ret_ref;
28398 }
28399
28400 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
28401         LDKOpenChannel this_ptr_conv;
28402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28403         this_ptr_conv.is_owned = false;
28404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28405         LDKChannelTypeFeatures val_conv;
28406         val_conv.inner = (void*)(val & (~1));
28407         val_conv.is_owned = (val & 1) || (val == 0);
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28409         val_conv = ChannelTypeFeatures_clone(&val_conv);
28410         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
28411 }
28412
28413 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
28414         LDKOpenChannel ret_var = OpenChannel_clone(arg);
28415 uint32_t ret_ref = 0;
28416 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28417 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28419 ret_ref = (uintptr_t)ret_var.inner;
28420 if (ret_var.is_owned) {
28421         ret_ref |= 1;
28422 }
28423         return ret_ref;
28424 }
28425 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
28426         LDKOpenChannel arg_conv;
28427         arg_conv.inner = (void*)(arg & (~1));
28428         arg_conv.is_owned = false;
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28430         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
28431         return ret_conv;
28432 }
28433
28434 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
28435         LDKOpenChannel orig_conv;
28436         orig_conv.inner = (void*)(orig & (~1));
28437         orig_conv.is_owned = false;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28439         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
28440         uint32_t ret_ref = 0;
28441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28444         ret_ref = (uintptr_t)ret_var.inner;
28445         if (ret_var.is_owned) {
28446                 ret_ref |= 1;
28447         }
28448         return ret_ref;
28449 }
28450
28451 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
28452         LDKAcceptChannel this_obj_conv;
28453         this_obj_conv.inner = (void*)(this_obj & (~1));
28454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28456         AcceptChannel_free(this_obj_conv);
28457 }
28458
28459 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
28460         LDKAcceptChannel this_ptr_conv;
28461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28462         this_ptr_conv.is_owned = false;
28463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28464         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28465         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28466         return ret_arr;
28467 }
28468
28469 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28470         LDKAcceptChannel this_ptr_conv;
28471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28472         this_ptr_conv.is_owned = false;
28473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28474         LDKThirtyTwoBytes val_ref;
28475         CHECK(val->arr_len == 32);
28476         memcpy(val_ref.data, val->elems, 32); FREE(val);
28477         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28478 }
28479
28480 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28481         LDKAcceptChannel this_ptr_conv;
28482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28483         this_ptr_conv.is_owned = false;
28484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28485         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
28486         return ret_conv;
28487 }
28488
28489 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28490         LDKAcceptChannel this_ptr_conv;
28491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28492         this_ptr_conv.is_owned = false;
28493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28494         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28495 }
28496
28497 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) {
28498         LDKAcceptChannel this_ptr_conv;
28499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28500         this_ptr_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28503         return ret_conv;
28504 }
28505
28506 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) {
28507         LDKAcceptChannel this_ptr_conv;
28508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28509         this_ptr_conv.is_owned = false;
28510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28511         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28512 }
28513
28514 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28515         LDKAcceptChannel this_ptr_conv;
28516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28517         this_ptr_conv.is_owned = false;
28518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28519         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28520         return ret_conv;
28521 }
28522
28523 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28524         LDKAcceptChannel this_ptr_conv;
28525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28526         this_ptr_conv.is_owned = false;
28527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28528         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28529 }
28530
28531 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28532         LDKAcceptChannel this_ptr_conv;
28533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28534         this_ptr_conv.is_owned = false;
28535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28536         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
28537         return ret_conv;
28538 }
28539
28540 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28541         LDKAcceptChannel this_ptr_conv;
28542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28543         this_ptr_conv.is_owned = false;
28544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28545         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28546 }
28547
28548 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
28549         LDKAcceptChannel this_ptr_conv;
28550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28551         this_ptr_conv.is_owned = false;
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28553         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
28554         return ret_conv;
28555 }
28556
28557 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
28558         LDKAcceptChannel this_ptr_conv;
28559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28560         this_ptr_conv.is_owned = false;
28561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28562         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
28563 }
28564
28565 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
28566         LDKAcceptChannel this_ptr_conv;
28567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28568         this_ptr_conv.is_owned = false;
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28570         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
28571         return ret_conv;
28572 }
28573
28574 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28575         LDKAcceptChannel this_ptr_conv;
28576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28577         this_ptr_conv.is_owned = false;
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28579         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
28580 }
28581
28582 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28583         LDKAcceptChannel this_ptr_conv;
28584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28585         this_ptr_conv.is_owned = false;
28586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28587         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
28588         return ret_conv;
28589 }
28590
28591 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28592         LDKAcceptChannel this_ptr_conv;
28593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28594         this_ptr_conv.is_owned = false;
28595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28596         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28597 }
28598
28599 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
28600         LDKAcceptChannel this_ptr_conv;
28601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28602         this_ptr_conv.is_owned = false;
28603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28604         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28605         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28606         return ret_arr;
28607 }
28608
28609 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28610         LDKAcceptChannel this_ptr_conv;
28611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28612         this_ptr_conv.is_owned = false;
28613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28614         LDKPublicKey val_ref;
28615         CHECK(val->arr_len == 33);
28616         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28617         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28618 }
28619
28620 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
28621         LDKAcceptChannel this_ptr_conv;
28622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28623         this_ptr_conv.is_owned = false;
28624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28625         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28626         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28627         return ret_arr;
28628 }
28629
28630 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28631         LDKAcceptChannel this_ptr_conv;
28632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28633         this_ptr_conv.is_owned = false;
28634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28635         LDKPublicKey val_ref;
28636         CHECK(val->arr_len == 33);
28637         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28638         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28639 }
28640
28641 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
28642         LDKAcceptChannel this_ptr_conv;
28643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28644         this_ptr_conv.is_owned = false;
28645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28646         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28647         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28648         return ret_arr;
28649 }
28650
28651 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28652         LDKAcceptChannel this_ptr_conv;
28653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28654         this_ptr_conv.is_owned = false;
28655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28656         LDKPublicKey val_ref;
28657         CHECK(val->arr_len == 33);
28658         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28659         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
28660 }
28661
28662 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28663         LDKAcceptChannel this_ptr_conv;
28664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28665         this_ptr_conv.is_owned = false;
28666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28667         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28668         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28669         return ret_arr;
28670 }
28671
28672 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28673         LDKAcceptChannel this_ptr_conv;
28674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28675         this_ptr_conv.is_owned = false;
28676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28677         LDKPublicKey val_ref;
28678         CHECK(val->arr_len == 33);
28679         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28680         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28681 }
28682
28683 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
28684         LDKAcceptChannel this_ptr_conv;
28685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28686         this_ptr_conv.is_owned = false;
28687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28688         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28689         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28690         return ret_arr;
28691 }
28692
28693 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28694         LDKAcceptChannel this_ptr_conv;
28695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28696         this_ptr_conv.is_owned = false;
28697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28698         LDKPublicKey val_ref;
28699         CHECK(val->arr_len == 33);
28700         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28701         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28702 }
28703
28704 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28705         LDKAcceptChannel this_ptr_conv;
28706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28707         this_ptr_conv.is_owned = false;
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28709         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28710         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28711         return ret_arr;
28712 }
28713
28714 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) {
28715         LDKAcceptChannel this_ptr_conv;
28716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28717         this_ptr_conv.is_owned = false;
28718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28719         LDKPublicKey val_ref;
28720         CHECK(val->arr_len == 33);
28721         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28722         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28723 }
28724
28725 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
28726         LDKAcceptChannel this_ptr_conv;
28727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28728         this_ptr_conv.is_owned = false;
28729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28730         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
28731         uint32_t ret_ref = 0;
28732         if ((uintptr_t)ret_var.inner > 4096) {
28733                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28734                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28736                 ret_ref = (uintptr_t)ret_var.inner;
28737                 if (ret_var.is_owned) {
28738                         ret_ref |= 1;
28739                 }
28740         }
28741         return ret_ref;
28742 }
28743
28744 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
28745         LDKAcceptChannel this_ptr_conv;
28746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28747         this_ptr_conv.is_owned = false;
28748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28749         LDKChannelTypeFeatures val_conv;
28750         val_conv.inner = (void*)(val & (~1));
28751         val_conv.is_owned = (val & 1) || (val == 0);
28752         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28753         val_conv = ChannelTypeFeatures_clone(&val_conv);
28754         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
28755 }
28756
28757 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
28758         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
28759 uint32_t ret_ref = 0;
28760 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28761 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28762 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28763 ret_ref = (uintptr_t)ret_var.inner;
28764 if (ret_var.is_owned) {
28765         ret_ref |= 1;
28766 }
28767         return ret_ref;
28768 }
28769 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
28770         LDKAcceptChannel arg_conv;
28771         arg_conv.inner = (void*)(arg & (~1));
28772         arg_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28774         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
28775         return ret_conv;
28776 }
28777
28778 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
28779         LDKAcceptChannel orig_conv;
28780         orig_conv.inner = (void*)(orig & (~1));
28781         orig_conv.is_owned = false;
28782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28783         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
28784         uint32_t ret_ref = 0;
28785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28788         ret_ref = (uintptr_t)ret_var.inner;
28789         if (ret_var.is_owned) {
28790                 ret_ref |= 1;
28791         }
28792         return ret_ref;
28793 }
28794
28795 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
28796         LDKFundingCreated this_obj_conv;
28797         this_obj_conv.inner = (void*)(this_obj & (~1));
28798         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28800         FundingCreated_free(this_obj_conv);
28801 }
28802
28803 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
28804         LDKFundingCreated this_ptr_conv;
28805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28806         this_ptr_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28808         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28809         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
28810         return ret_arr;
28811 }
28812
28813 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28814         LDKFundingCreated this_ptr_conv;
28815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28816         this_ptr_conv.is_owned = false;
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28818         LDKThirtyTwoBytes val_ref;
28819         CHECK(val->arr_len == 32);
28820         memcpy(val_ref.data, val->elems, 32); FREE(val);
28821         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
28822 }
28823
28824 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
28825         LDKFundingCreated this_ptr_conv;
28826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28827         this_ptr_conv.is_owned = false;
28828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28829         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28830         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
28831         return ret_arr;
28832 }
28833
28834 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
28835         LDKFundingCreated 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         LDKThirtyTwoBytes val_ref;
28840         CHECK(val->arr_len == 32);
28841         memcpy(val_ref.data, val->elems, 32); FREE(val);
28842         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
28843 }
28844
28845 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
28846         LDKFundingCreated this_ptr_conv;
28847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28848         this_ptr_conv.is_owned = false;
28849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28850         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
28851         return ret_conv;
28852 }
28853
28854 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
28855         LDKFundingCreated this_ptr_conv;
28856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28857         this_ptr_conv.is_owned = false;
28858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28859         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
28860 }
28861
28862 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
28863         LDKFundingCreated this_ptr_conv;
28864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28865         this_ptr_conv.is_owned = false;
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28867         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28868         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
28869         return ret_arr;
28870 }
28871
28872 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
28873         LDKFundingCreated this_ptr_conv;
28874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28875         this_ptr_conv.is_owned = false;
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28877         LDKSignature val_ref;
28878         CHECK(val->arr_len == 64);
28879         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28880         FundingCreated_set_signature(&this_ptr_conv, val_ref);
28881 }
28882
28883 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) {
28884         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
28885         CHECK(temporary_channel_id_arg->arr_len == 32);
28886         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
28887         LDKThirtyTwoBytes funding_txid_arg_ref;
28888         CHECK(funding_txid_arg->arr_len == 32);
28889         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
28890         LDKSignature signature_arg_ref;
28891         CHECK(signature_arg->arr_len == 64);
28892         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28893         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
28894         uint32_t ret_ref = 0;
28895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28898         ret_ref = (uintptr_t)ret_var.inner;
28899         if (ret_var.is_owned) {
28900                 ret_ref |= 1;
28901         }
28902         return ret_ref;
28903 }
28904
28905 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
28906         LDKFundingCreated ret_var = FundingCreated_clone(arg);
28907 uint32_t ret_ref = 0;
28908 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28909 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28910 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28911 ret_ref = (uintptr_t)ret_var.inner;
28912 if (ret_var.is_owned) {
28913         ret_ref |= 1;
28914 }
28915         return ret_ref;
28916 }
28917 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
28918         LDKFundingCreated arg_conv;
28919         arg_conv.inner = (void*)(arg & (~1));
28920         arg_conv.is_owned = false;
28921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28922         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
28923         return ret_conv;
28924 }
28925
28926 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
28927         LDKFundingCreated orig_conv;
28928         orig_conv.inner = (void*)(orig & (~1));
28929         orig_conv.is_owned = false;
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28931         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
28932         uint32_t ret_ref = 0;
28933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28936         ret_ref = (uintptr_t)ret_var.inner;
28937         if (ret_var.is_owned) {
28938                 ret_ref |= 1;
28939         }
28940         return ret_ref;
28941 }
28942
28943 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
28944         LDKFundingSigned this_obj_conv;
28945         this_obj_conv.inner = (void*)(this_obj & (~1));
28946         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28948         FundingSigned_free(this_obj_conv);
28949 }
28950
28951 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
28952         LDKFundingSigned this_ptr_conv;
28953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28954         this_ptr_conv.is_owned = false;
28955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28956         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28957         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
28958         return ret_arr;
28959 }
28960
28961 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28962         LDKFundingSigned this_ptr_conv;
28963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28964         this_ptr_conv.is_owned = false;
28965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28966         LDKThirtyTwoBytes val_ref;
28967         CHECK(val->arr_len == 32);
28968         memcpy(val_ref.data, val->elems, 32); FREE(val);
28969         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
28970 }
28971
28972 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
28973         LDKFundingSigned this_ptr_conv;
28974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28975         this_ptr_conv.is_owned = false;
28976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28977         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28978         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28979         return ret_arr;
28980 }
28981
28982 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28983         LDKFundingSigned this_ptr_conv;
28984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28985         this_ptr_conv.is_owned = false;
28986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28987         LDKSignature val_ref;
28988         CHECK(val->arr_len == 64);
28989         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28990         FundingSigned_set_signature(&this_ptr_conv, val_ref);
28991 }
28992
28993 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
28994         LDKThirtyTwoBytes channel_id_arg_ref;
28995         CHECK(channel_id_arg->arr_len == 32);
28996         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28997         LDKSignature signature_arg_ref;
28998         CHECK(signature_arg->arr_len == 64);
28999         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29000         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29001         uint32_t ret_ref = 0;
29002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29005         ret_ref = (uintptr_t)ret_var.inner;
29006         if (ret_var.is_owned) {
29007                 ret_ref |= 1;
29008         }
29009         return ret_ref;
29010 }
29011
29012 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29013         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29014 uint32_t ret_ref = 0;
29015 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29016 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29017 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29018 ret_ref = (uintptr_t)ret_var.inner;
29019 if (ret_var.is_owned) {
29020         ret_ref |= 1;
29021 }
29022         return ret_ref;
29023 }
29024 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
29025         LDKFundingSigned arg_conv;
29026         arg_conv.inner = (void*)(arg & (~1));
29027         arg_conv.is_owned = false;
29028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29029         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29030         return ret_conv;
29031 }
29032
29033 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
29034         LDKFundingSigned orig_conv;
29035         orig_conv.inner = (void*)(orig & (~1));
29036         orig_conv.is_owned = false;
29037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29038         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29039         uint32_t ret_ref = 0;
29040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29043         ret_ref = (uintptr_t)ret_var.inner;
29044         if (ret_var.is_owned) {
29045                 ret_ref |= 1;
29046         }
29047         return ret_ref;
29048 }
29049
29050 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
29051         LDKChannelReady this_obj_conv;
29052         this_obj_conv.inner = (void*)(this_obj & (~1));
29053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29055         ChannelReady_free(this_obj_conv);
29056 }
29057
29058 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
29059         LDKChannelReady this_ptr_conv;
29060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29061         this_ptr_conv.is_owned = false;
29062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29063         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29064         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29065         return ret_arr;
29066 }
29067
29068 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29069         LDKChannelReady this_ptr_conv;
29070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29071         this_ptr_conv.is_owned = false;
29072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29073         LDKThirtyTwoBytes val_ref;
29074         CHECK(val->arr_len == 32);
29075         memcpy(val_ref.data, val->elems, 32); FREE(val);
29076         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29077 }
29078
29079 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
29080         LDKChannelReady this_ptr_conv;
29081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29082         this_ptr_conv.is_owned = false;
29083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29084         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29085         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29086         return ret_arr;
29087 }
29088
29089 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) {
29090         LDKChannelReady this_ptr_conv;
29091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29092         this_ptr_conv.is_owned = false;
29093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29094         LDKPublicKey val_ref;
29095         CHECK(val->arr_len == 33);
29096         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29097         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29098 }
29099
29100 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
29101         LDKChannelReady this_ptr_conv;
29102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29103         this_ptr_conv.is_owned = false;
29104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29105         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29106         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29107         uint32_t ret_ref = (uintptr_t)ret_copy;
29108         return ret_ref;
29109 }
29110
29111 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) {
29112         LDKChannelReady this_ptr_conv;
29113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29114         this_ptr_conv.is_owned = false;
29115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29116         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29117         CHECK_ACCESS(val_ptr);
29118         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29119         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29120         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29121 }
29122
29123 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) {
29124         LDKThirtyTwoBytes channel_id_arg_ref;
29125         CHECK(channel_id_arg->arr_len == 32);
29126         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29127         LDKPublicKey next_per_commitment_point_arg_ref;
29128         CHECK(next_per_commitment_point_arg->arr_len == 33);
29129         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29130         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
29131         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29132         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29133         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
29134         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29135         uint32_t ret_ref = 0;
29136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29139         ret_ref = (uintptr_t)ret_var.inner;
29140         if (ret_var.is_owned) {
29141                 ret_ref |= 1;
29142         }
29143         return ret_ref;
29144 }
29145
29146 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29147         LDKChannelReady ret_var = ChannelReady_clone(arg);
29148 uint32_t ret_ref = 0;
29149 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29150 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29152 ret_ref = (uintptr_t)ret_var.inner;
29153 if (ret_var.is_owned) {
29154         ret_ref |= 1;
29155 }
29156         return ret_ref;
29157 }
29158 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
29159         LDKChannelReady arg_conv;
29160         arg_conv.inner = (void*)(arg & (~1));
29161         arg_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29163         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29164         return ret_conv;
29165 }
29166
29167 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
29168         LDKChannelReady orig_conv;
29169         orig_conv.inner = (void*)(orig & (~1));
29170         orig_conv.is_owned = false;
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29172         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29173         uint32_t ret_ref = 0;
29174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29177         ret_ref = (uintptr_t)ret_var.inner;
29178         if (ret_var.is_owned) {
29179                 ret_ref |= 1;
29180         }
29181         return ret_ref;
29182 }
29183
29184 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
29185         LDKShutdown this_obj_conv;
29186         this_obj_conv.inner = (void*)(this_obj & (~1));
29187         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29189         Shutdown_free(this_obj_conv);
29190 }
29191
29192 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
29193         LDKShutdown this_ptr_conv;
29194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29195         this_ptr_conv.is_owned = false;
29196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29197         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29198         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29199         return ret_arr;
29200 }
29201
29202 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29203         LDKShutdown this_ptr_conv;
29204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29205         this_ptr_conv.is_owned = false;
29206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29207         LDKThirtyTwoBytes val_ref;
29208         CHECK(val->arr_len == 32);
29209         memcpy(val_ref.data, val->elems, 32); FREE(val);
29210         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29211 }
29212
29213 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
29214         LDKShutdown this_ptr_conv;
29215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29216         this_ptr_conv.is_owned = false;
29217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29218         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29219         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29220         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29221         return ret_arr;
29222 }
29223
29224 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
29225         LDKShutdown this_ptr_conv;
29226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29227         this_ptr_conv.is_owned = false;
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29229         LDKCVec_u8Z val_ref;
29230         val_ref.datalen = val->arr_len;
29231         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29232         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29233         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29234 }
29235
29236 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29237         LDKThirtyTwoBytes channel_id_arg_ref;
29238         CHECK(channel_id_arg->arr_len == 32);
29239         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29240         LDKCVec_u8Z scriptpubkey_arg_ref;
29241         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29242         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29243         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29244         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29245         uint32_t ret_ref = 0;
29246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29249         ret_ref = (uintptr_t)ret_var.inner;
29250         if (ret_var.is_owned) {
29251                 ret_ref |= 1;
29252         }
29253         return ret_ref;
29254 }
29255
29256 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29257         LDKShutdown ret_var = Shutdown_clone(arg);
29258 uint32_t ret_ref = 0;
29259 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29260 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29261 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29262 ret_ref = (uintptr_t)ret_var.inner;
29263 if (ret_var.is_owned) {
29264         ret_ref |= 1;
29265 }
29266         return ret_ref;
29267 }
29268 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
29269         LDKShutdown arg_conv;
29270         arg_conv.inner = (void*)(arg & (~1));
29271         arg_conv.is_owned = false;
29272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29273         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29274         return ret_conv;
29275 }
29276
29277 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
29278         LDKShutdown orig_conv;
29279         orig_conv.inner = (void*)(orig & (~1));
29280         orig_conv.is_owned = false;
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29282         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29283         uint32_t ret_ref = 0;
29284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29287         ret_ref = (uintptr_t)ret_var.inner;
29288         if (ret_var.is_owned) {
29289                 ret_ref |= 1;
29290         }
29291         return ret_ref;
29292 }
29293
29294 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
29295         LDKClosingSignedFeeRange this_obj_conv;
29296         this_obj_conv.inner = (void*)(this_obj & (~1));
29297         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29299         ClosingSignedFeeRange_free(this_obj_conv);
29300 }
29301
29302 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
29303         LDKClosingSignedFeeRange this_ptr_conv;
29304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29305         this_ptr_conv.is_owned = false;
29306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29307         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29308         return ret_conv;
29309 }
29310
29311 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
29312         LDKClosingSignedFeeRange this_ptr_conv;
29313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29314         this_ptr_conv.is_owned = false;
29315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29316         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29317 }
29318
29319 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
29320         LDKClosingSignedFeeRange 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         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29325         return ret_conv;
29326 }
29327
29328 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
29329         LDKClosingSignedFeeRange this_ptr_conv;
29330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29331         this_ptr_conv.is_owned = false;
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29333         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
29334 }
29335
29336 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
29337         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
29338         uint32_t ret_ref = 0;
29339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29342         ret_ref = (uintptr_t)ret_var.inner;
29343         if (ret_var.is_owned) {
29344                 ret_ref |= 1;
29345         }
29346         return ret_ref;
29347 }
29348
29349 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
29350         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
29351 uint32_t ret_ref = 0;
29352 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29353 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29354 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29355 ret_ref = (uintptr_t)ret_var.inner;
29356 if (ret_var.is_owned) {
29357         ret_ref |= 1;
29358 }
29359         return ret_ref;
29360 }
29361 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
29362         LDKClosingSignedFeeRange arg_conv;
29363         arg_conv.inner = (void*)(arg & (~1));
29364         arg_conv.is_owned = false;
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29366         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
29367         return ret_conv;
29368 }
29369
29370 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
29371         LDKClosingSignedFeeRange orig_conv;
29372         orig_conv.inner = (void*)(orig & (~1));
29373         orig_conv.is_owned = false;
29374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29375         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
29376         uint32_t ret_ref = 0;
29377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29380         ret_ref = (uintptr_t)ret_var.inner;
29381         if (ret_var.is_owned) {
29382                 ret_ref |= 1;
29383         }
29384         return ret_ref;
29385 }
29386
29387 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
29388         LDKClosingSigned this_obj_conv;
29389         this_obj_conv.inner = (void*)(this_obj & (~1));
29390         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29392         ClosingSigned_free(this_obj_conv);
29393 }
29394
29395 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
29396         LDKClosingSigned this_ptr_conv;
29397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29398         this_ptr_conv.is_owned = false;
29399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29400         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29401         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
29402         return ret_arr;
29403 }
29404
29405 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29406         LDKClosingSigned this_ptr_conv;
29407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29408         this_ptr_conv.is_owned = false;
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29410         LDKThirtyTwoBytes val_ref;
29411         CHECK(val->arr_len == 32);
29412         memcpy(val_ref.data, val->elems, 32); FREE(val);
29413         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
29414 }
29415
29416 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
29417         LDKClosingSigned this_ptr_conv;
29418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29419         this_ptr_conv.is_owned = false;
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29421         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
29422         return ret_conv;
29423 }
29424
29425 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
29426         LDKClosingSigned this_ptr_conv;
29427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29428         this_ptr_conv.is_owned = false;
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29430         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
29431 }
29432
29433 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
29434         LDKClosingSigned this_ptr_conv;
29435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29436         this_ptr_conv.is_owned = false;
29437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29438         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29439         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29440         return ret_arr;
29441 }
29442
29443 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29444         LDKClosingSigned this_ptr_conv;
29445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29446         this_ptr_conv.is_owned = false;
29447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29448         LDKSignature val_ref;
29449         CHECK(val->arr_len == 64);
29450         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29451         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
29452 }
29453
29454 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
29455         LDKClosingSigned this_ptr_conv;
29456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29457         this_ptr_conv.is_owned = false;
29458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29459         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
29460         uint32_t ret_ref = 0;
29461         if ((uintptr_t)ret_var.inner > 4096) {
29462                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29463                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29465                 ret_ref = (uintptr_t)ret_var.inner;
29466                 if (ret_var.is_owned) {
29467                         ret_ref |= 1;
29468                 }
29469         }
29470         return ret_ref;
29471 }
29472
29473 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
29474         LDKClosingSigned this_ptr_conv;
29475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29476         this_ptr_conv.is_owned = false;
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29478         LDKClosingSignedFeeRange val_conv;
29479         val_conv.inner = (void*)(val & (~1));
29480         val_conv.is_owned = (val & 1) || (val == 0);
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29482         val_conv = ClosingSignedFeeRange_clone(&val_conv);
29483         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
29484 }
29485
29486 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) {
29487         LDKThirtyTwoBytes channel_id_arg_ref;
29488         CHECK(channel_id_arg->arr_len == 32);
29489         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29490         LDKSignature signature_arg_ref;
29491         CHECK(signature_arg->arr_len == 64);
29492         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29493         LDKClosingSignedFeeRange fee_range_arg_conv;
29494         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
29495         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
29497         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
29498         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
29499         uint32_t ret_ref = 0;
29500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29503         ret_ref = (uintptr_t)ret_var.inner;
29504         if (ret_var.is_owned) {
29505                 ret_ref |= 1;
29506         }
29507         return ret_ref;
29508 }
29509
29510 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
29511         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
29512 uint32_t ret_ref = 0;
29513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29516 ret_ref = (uintptr_t)ret_var.inner;
29517 if (ret_var.is_owned) {
29518         ret_ref |= 1;
29519 }
29520         return ret_ref;
29521 }
29522 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
29523         LDKClosingSigned arg_conv;
29524         arg_conv.inner = (void*)(arg & (~1));
29525         arg_conv.is_owned = false;
29526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29527         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
29528         return ret_conv;
29529 }
29530
29531 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
29532         LDKClosingSigned orig_conv;
29533         orig_conv.inner = (void*)(orig & (~1));
29534         orig_conv.is_owned = false;
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29536         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
29537         uint32_t ret_ref = 0;
29538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29541         ret_ref = (uintptr_t)ret_var.inner;
29542         if (ret_var.is_owned) {
29543                 ret_ref |= 1;
29544         }
29545         return ret_ref;
29546 }
29547
29548 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
29549         LDKUpdateAddHTLC this_obj_conv;
29550         this_obj_conv.inner = (void*)(this_obj & (~1));
29551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29553         UpdateAddHTLC_free(this_obj_conv);
29554 }
29555
29556 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
29557         LDKUpdateAddHTLC this_ptr_conv;
29558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29559         this_ptr_conv.is_owned = false;
29560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29561         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29562         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
29563         return ret_arr;
29564 }
29565
29566 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29567         LDKUpdateAddHTLC this_ptr_conv;
29568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29569         this_ptr_conv.is_owned = false;
29570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29571         LDKThirtyTwoBytes val_ref;
29572         CHECK(val->arr_len == 32);
29573         memcpy(val_ref.data, val->elems, 32); FREE(val);
29574         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
29575 }
29576
29577 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
29578         LDKUpdateAddHTLC this_ptr_conv;
29579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29580         this_ptr_conv.is_owned = false;
29581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29582         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
29583         return ret_conv;
29584 }
29585
29586 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29587         LDKUpdateAddHTLC this_ptr_conv;
29588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29589         this_ptr_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29591         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
29592 }
29593
29594 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
29595         LDKUpdateAddHTLC this_ptr_conv;
29596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29597         this_ptr_conv.is_owned = false;
29598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29599         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
29600         return ret_conv;
29601 }
29602
29603 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
29604         LDKUpdateAddHTLC this_ptr_conv;
29605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29606         this_ptr_conv.is_owned = false;
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29608         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
29609 }
29610
29611 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
29612         LDKUpdateAddHTLC this_ptr_conv;
29613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29614         this_ptr_conv.is_owned = false;
29615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29616         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29617         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
29618         return ret_arr;
29619 }
29620
29621 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29622         LDKUpdateAddHTLC this_ptr_conv;
29623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29624         this_ptr_conv.is_owned = false;
29625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29626         LDKThirtyTwoBytes val_ref;
29627         CHECK(val->arr_len == 32);
29628         memcpy(val_ref.data, val->elems, 32); FREE(val);
29629         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
29630 }
29631
29632 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
29633         LDKUpdateAddHTLC this_ptr_conv;
29634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29635         this_ptr_conv.is_owned = false;
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29637         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
29638         return ret_conv;
29639 }
29640
29641 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29642         LDKUpdateAddHTLC this_ptr_conv;
29643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29644         this_ptr_conv.is_owned = false;
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29646         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
29647 }
29648
29649 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
29650         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
29651 uint32_t ret_ref = 0;
29652 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29653 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29654 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29655 ret_ref = (uintptr_t)ret_var.inner;
29656 if (ret_var.is_owned) {
29657         ret_ref |= 1;
29658 }
29659         return ret_ref;
29660 }
29661 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
29662         LDKUpdateAddHTLC arg_conv;
29663         arg_conv.inner = (void*)(arg & (~1));
29664         arg_conv.is_owned = false;
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29666         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
29667         return ret_conv;
29668 }
29669
29670 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
29671         LDKUpdateAddHTLC orig_conv;
29672         orig_conv.inner = (void*)(orig & (~1));
29673         orig_conv.is_owned = false;
29674         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29675         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
29676         uint32_t ret_ref = 0;
29677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29680         ret_ref = (uintptr_t)ret_var.inner;
29681         if (ret_var.is_owned) {
29682                 ret_ref |= 1;
29683         }
29684         return ret_ref;
29685 }
29686
29687 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
29688         LDKUpdateFulfillHTLC this_obj_conv;
29689         this_obj_conv.inner = (void*)(this_obj & (~1));
29690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29692         UpdateFulfillHTLC_free(this_obj_conv);
29693 }
29694
29695 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
29696         LDKUpdateFulfillHTLC this_ptr_conv;
29697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29698         this_ptr_conv.is_owned = false;
29699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29700         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29701         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
29702         return ret_arr;
29703 }
29704
29705 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29706         LDKUpdateFulfillHTLC 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         LDKThirtyTwoBytes val_ref;
29711         CHECK(val->arr_len == 32);
29712         memcpy(val_ref.data, val->elems, 32); FREE(val);
29713         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
29714 }
29715
29716 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
29717         LDKUpdateFulfillHTLC this_ptr_conv;
29718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29719         this_ptr_conv.is_owned = false;
29720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29721         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
29722         return ret_conv;
29723 }
29724
29725 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29726         LDKUpdateFulfillHTLC this_ptr_conv;
29727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29728         this_ptr_conv.is_owned = false;
29729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29730         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
29731 }
29732
29733 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
29734         LDKUpdateFulfillHTLC this_ptr_conv;
29735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29736         this_ptr_conv.is_owned = false;
29737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29738         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29739         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
29740         return ret_arr;
29741 }
29742
29743 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
29744         LDKUpdateFulfillHTLC this_ptr_conv;
29745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29746         this_ptr_conv.is_owned = false;
29747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29748         LDKThirtyTwoBytes val_ref;
29749         CHECK(val->arr_len == 32);
29750         memcpy(val_ref.data, val->elems, 32); FREE(val);
29751         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
29752 }
29753
29754 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) {
29755         LDKThirtyTwoBytes channel_id_arg_ref;
29756         CHECK(channel_id_arg->arr_len == 32);
29757         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29758         LDKThirtyTwoBytes payment_preimage_arg_ref;
29759         CHECK(payment_preimage_arg->arr_len == 32);
29760         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
29761         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
29762         uint32_t ret_ref = 0;
29763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29766         ret_ref = (uintptr_t)ret_var.inner;
29767         if (ret_var.is_owned) {
29768                 ret_ref |= 1;
29769         }
29770         return ret_ref;
29771 }
29772
29773 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
29774         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
29775 uint32_t ret_ref = 0;
29776 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29777 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29778 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29779 ret_ref = (uintptr_t)ret_var.inner;
29780 if (ret_var.is_owned) {
29781         ret_ref |= 1;
29782 }
29783         return ret_ref;
29784 }
29785 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
29786         LDKUpdateFulfillHTLC arg_conv;
29787         arg_conv.inner = (void*)(arg & (~1));
29788         arg_conv.is_owned = false;
29789         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29790         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
29791         return ret_conv;
29792 }
29793
29794 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
29795         LDKUpdateFulfillHTLC orig_conv;
29796         orig_conv.inner = (void*)(orig & (~1));
29797         orig_conv.is_owned = false;
29798         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29799         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
29800         uint32_t ret_ref = 0;
29801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29804         ret_ref = (uintptr_t)ret_var.inner;
29805         if (ret_var.is_owned) {
29806                 ret_ref |= 1;
29807         }
29808         return ret_ref;
29809 }
29810
29811 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
29812         LDKUpdateFailHTLC this_obj_conv;
29813         this_obj_conv.inner = (void*)(this_obj & (~1));
29814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29816         UpdateFailHTLC_free(this_obj_conv);
29817 }
29818
29819 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
29820         LDKUpdateFailHTLC this_ptr_conv;
29821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29822         this_ptr_conv.is_owned = false;
29823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29824         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29825         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
29826         return ret_arr;
29827 }
29828
29829 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29830         LDKUpdateFailHTLC this_ptr_conv;
29831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29832         this_ptr_conv.is_owned = false;
29833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29834         LDKThirtyTwoBytes val_ref;
29835         CHECK(val->arr_len == 32);
29836         memcpy(val_ref.data, val->elems, 32); FREE(val);
29837         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
29838 }
29839
29840 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
29841         LDKUpdateFailHTLC this_ptr_conv;
29842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29843         this_ptr_conv.is_owned = false;
29844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29845         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
29846         return ret_conv;
29847 }
29848
29849 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29850         LDKUpdateFailHTLC 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         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
29855 }
29856
29857 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
29858         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
29859 uint32_t ret_ref = 0;
29860 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29861 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29862 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29863 ret_ref = (uintptr_t)ret_var.inner;
29864 if (ret_var.is_owned) {
29865         ret_ref |= 1;
29866 }
29867         return ret_ref;
29868 }
29869 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
29870         LDKUpdateFailHTLC arg_conv;
29871         arg_conv.inner = (void*)(arg & (~1));
29872         arg_conv.is_owned = false;
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29874         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
29875         return ret_conv;
29876 }
29877
29878 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
29879         LDKUpdateFailHTLC orig_conv;
29880         orig_conv.inner = (void*)(orig & (~1));
29881         orig_conv.is_owned = false;
29882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29883         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
29884         uint32_t ret_ref = 0;
29885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29888         ret_ref = (uintptr_t)ret_var.inner;
29889         if (ret_var.is_owned) {
29890                 ret_ref |= 1;
29891         }
29892         return ret_ref;
29893 }
29894
29895 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
29896         LDKUpdateFailMalformedHTLC this_obj_conv;
29897         this_obj_conv.inner = (void*)(this_obj & (~1));
29898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29900         UpdateFailMalformedHTLC_free(this_obj_conv);
29901 }
29902
29903 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
29904         LDKUpdateFailMalformedHTLC this_ptr_conv;
29905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29906         this_ptr_conv.is_owned = false;
29907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29908         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29909         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
29910         return ret_arr;
29911 }
29912
29913 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29914         LDKUpdateFailMalformedHTLC this_ptr_conv;
29915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29916         this_ptr_conv.is_owned = false;
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29918         LDKThirtyTwoBytes val_ref;
29919         CHECK(val->arr_len == 32);
29920         memcpy(val_ref.data, val->elems, 32); FREE(val);
29921         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
29922 }
29923
29924 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
29925         LDKUpdateFailMalformedHTLC this_ptr_conv;
29926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29927         this_ptr_conv.is_owned = false;
29928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29929         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
29930         return ret_conv;
29931 }
29932
29933 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29934         LDKUpdateFailMalformedHTLC this_ptr_conv;
29935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29936         this_ptr_conv.is_owned = false;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29938         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
29939 }
29940
29941 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
29942         LDKUpdateFailMalformedHTLC this_ptr_conv;
29943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29944         this_ptr_conv.is_owned = false;
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29946         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
29947         return ret_conv;
29948 }
29949
29950 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
29951         LDKUpdateFailMalformedHTLC this_ptr_conv;
29952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29953         this_ptr_conv.is_owned = false;
29954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29955         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
29956 }
29957
29958 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
29959         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
29960 uint32_t ret_ref = 0;
29961 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29962 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29963 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29964 ret_ref = (uintptr_t)ret_var.inner;
29965 if (ret_var.is_owned) {
29966         ret_ref |= 1;
29967 }
29968         return ret_ref;
29969 }
29970 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
29971         LDKUpdateFailMalformedHTLC arg_conv;
29972         arg_conv.inner = (void*)(arg & (~1));
29973         arg_conv.is_owned = false;
29974         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29975         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
29976         return ret_conv;
29977 }
29978
29979 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
29980         LDKUpdateFailMalformedHTLC orig_conv;
29981         orig_conv.inner = (void*)(orig & (~1));
29982         orig_conv.is_owned = false;
29983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29984         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
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 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
29997         LDKCommitmentSigned this_obj_conv;
29998         this_obj_conv.inner = (void*)(this_obj & (~1));
29999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30001         CommitmentSigned_free(this_obj_conv);
30002 }
30003
30004 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
30005         LDKCommitmentSigned this_ptr_conv;
30006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30007         this_ptr_conv.is_owned = false;
30008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30009         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30010         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30011         return ret_arr;
30012 }
30013
30014 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30015         LDKCommitmentSigned this_ptr_conv;
30016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30017         this_ptr_conv.is_owned = false;
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30019         LDKThirtyTwoBytes val_ref;
30020         CHECK(val->arr_len == 32);
30021         memcpy(val_ref.data, val->elems, 32); FREE(val);
30022         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30023 }
30024
30025 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
30026         LDKCommitmentSigned this_ptr_conv;
30027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30028         this_ptr_conv.is_owned = false;
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30030         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30031         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30032         return ret_arr;
30033 }
30034
30035 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30036         LDKCommitmentSigned this_ptr_conv;
30037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30038         this_ptr_conv.is_owned = false;
30039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30040         LDKSignature val_ref;
30041         CHECK(val->arr_len == 64);
30042         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30043         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30044 }
30045
30046 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
30047         LDKCommitmentSigned this_ptr_conv;
30048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30049         this_ptr_conv.is_owned = false;
30050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30051         LDKCVec_SignatureZ val_constr;
30052         val_constr.datalen = val->arr_len;
30053         if (val_constr.datalen > 0)
30054                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30055         else
30056                 val_constr.data = NULL;
30057         int8_tArray* val_vals = (void*) val->elems;
30058         for (size_t m = 0; m < val_constr.datalen; m++) {
30059                 int8_tArray val_conv_12 = val_vals[m];
30060                 LDKSignature val_conv_12_ref;
30061                 CHECK(val_conv_12->arr_len == 64);
30062                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30063                 val_constr.data[m] = val_conv_12_ref;
30064         }
30065         FREE(val);
30066         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30067 }
30068
30069 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30070         LDKThirtyTwoBytes channel_id_arg_ref;
30071         CHECK(channel_id_arg->arr_len == 32);
30072         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30073         LDKSignature signature_arg_ref;
30074         CHECK(signature_arg->arr_len == 64);
30075         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30076         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30077         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30078         if (htlc_signatures_arg_constr.datalen > 0)
30079                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30080         else
30081                 htlc_signatures_arg_constr.data = NULL;
30082         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30083         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30084                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30085                 LDKSignature htlc_signatures_arg_conv_12_ref;
30086                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30087                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30088                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30089         }
30090         FREE(htlc_signatures_arg);
30091         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30092         uint32_t ret_ref = 0;
30093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30096         ret_ref = (uintptr_t)ret_var.inner;
30097         if (ret_var.is_owned) {
30098                 ret_ref |= 1;
30099         }
30100         return ret_ref;
30101 }
30102
30103 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30104         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30105 uint32_t ret_ref = 0;
30106 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30107 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30108 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30109 ret_ref = (uintptr_t)ret_var.inner;
30110 if (ret_var.is_owned) {
30111         ret_ref |= 1;
30112 }
30113         return ret_ref;
30114 }
30115 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
30116         LDKCommitmentSigned arg_conv;
30117         arg_conv.inner = (void*)(arg & (~1));
30118         arg_conv.is_owned = false;
30119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30120         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30121         return ret_conv;
30122 }
30123
30124 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
30125         LDKCommitmentSigned orig_conv;
30126         orig_conv.inner = (void*)(orig & (~1));
30127         orig_conv.is_owned = false;
30128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30129         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30130         uint32_t ret_ref = 0;
30131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30134         ret_ref = (uintptr_t)ret_var.inner;
30135         if (ret_var.is_owned) {
30136                 ret_ref |= 1;
30137         }
30138         return ret_ref;
30139 }
30140
30141 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
30142         LDKRevokeAndACK this_obj_conv;
30143         this_obj_conv.inner = (void*)(this_obj & (~1));
30144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30146         RevokeAndACK_free(this_obj_conv);
30147 }
30148
30149 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
30150         LDKRevokeAndACK this_ptr_conv;
30151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30152         this_ptr_conv.is_owned = false;
30153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30154         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30155         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30156         return ret_arr;
30157 }
30158
30159 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30160         LDKRevokeAndACK this_ptr_conv;
30161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30162         this_ptr_conv.is_owned = false;
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30164         LDKThirtyTwoBytes val_ref;
30165         CHECK(val->arr_len == 32);
30166         memcpy(val_ref.data, val->elems, 32); FREE(val);
30167         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30168 }
30169
30170 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
30171         LDKRevokeAndACK this_ptr_conv;
30172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30173         this_ptr_conv.is_owned = false;
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30175         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30176         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30177         return ret_arr;
30178 }
30179
30180 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
30181         LDKRevokeAndACK this_ptr_conv;
30182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30183         this_ptr_conv.is_owned = false;
30184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30185         LDKThirtyTwoBytes val_ref;
30186         CHECK(val->arr_len == 32);
30187         memcpy(val_ref.data, val->elems, 32); FREE(val);
30188         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30189 }
30190
30191 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
30192         LDKRevokeAndACK this_ptr_conv;
30193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30194         this_ptr_conv.is_owned = false;
30195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30196         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30197         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30198         return ret_arr;
30199 }
30200
30201 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) {
30202         LDKRevokeAndACK this_ptr_conv;
30203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30204         this_ptr_conv.is_owned = false;
30205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30206         LDKPublicKey val_ref;
30207         CHECK(val->arr_len == 33);
30208         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30209         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30210 }
30211
30212 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) {
30213         LDKThirtyTwoBytes channel_id_arg_ref;
30214         CHECK(channel_id_arg->arr_len == 32);
30215         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30216         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30217         CHECK(per_commitment_secret_arg->arr_len == 32);
30218         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30219         LDKPublicKey next_per_commitment_point_arg_ref;
30220         CHECK(next_per_commitment_point_arg->arr_len == 33);
30221         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30222         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30223         uint32_t ret_ref = 0;
30224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30227         ret_ref = (uintptr_t)ret_var.inner;
30228         if (ret_var.is_owned) {
30229                 ret_ref |= 1;
30230         }
30231         return ret_ref;
30232 }
30233
30234 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30235         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30236 uint32_t ret_ref = 0;
30237 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30238 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30239 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30240 ret_ref = (uintptr_t)ret_var.inner;
30241 if (ret_var.is_owned) {
30242         ret_ref |= 1;
30243 }
30244         return ret_ref;
30245 }
30246 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
30247         LDKRevokeAndACK arg_conv;
30248         arg_conv.inner = (void*)(arg & (~1));
30249         arg_conv.is_owned = false;
30250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30251         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30252         return ret_conv;
30253 }
30254
30255 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
30256         LDKRevokeAndACK orig_conv;
30257         orig_conv.inner = (void*)(orig & (~1));
30258         orig_conv.is_owned = false;
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30260         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30261         uint32_t ret_ref = 0;
30262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30265         ret_ref = (uintptr_t)ret_var.inner;
30266         if (ret_var.is_owned) {
30267                 ret_ref |= 1;
30268         }
30269         return ret_ref;
30270 }
30271
30272 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
30273         LDKUpdateFee this_obj_conv;
30274         this_obj_conv.inner = (void*)(this_obj & (~1));
30275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30277         UpdateFee_free(this_obj_conv);
30278 }
30279
30280 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
30281         LDKUpdateFee this_ptr_conv;
30282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30283         this_ptr_conv.is_owned = false;
30284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30285         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30286         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30287         return ret_arr;
30288 }
30289
30290 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30291         LDKUpdateFee this_ptr_conv;
30292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30293         this_ptr_conv.is_owned = false;
30294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30295         LDKThirtyTwoBytes val_ref;
30296         CHECK(val->arr_len == 32);
30297         memcpy(val_ref.data, val->elems, 32); FREE(val);
30298         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30299 }
30300
30301 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
30302         LDKUpdateFee this_ptr_conv;
30303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30304         this_ptr_conv.is_owned = false;
30305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30306         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30307         return ret_conv;
30308 }
30309
30310 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
30311         LDKUpdateFee this_ptr_conv;
30312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30313         this_ptr_conv.is_owned = false;
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30315         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
30316 }
30317
30318 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
30319         LDKThirtyTwoBytes channel_id_arg_ref;
30320         CHECK(channel_id_arg->arr_len == 32);
30321         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30322         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
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 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
30335         LDKUpdateFee ret_var = UpdateFee_clone(arg);
30336 uint32_t ret_ref = 0;
30337 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30338 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30339 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30340 ret_ref = (uintptr_t)ret_var.inner;
30341 if (ret_var.is_owned) {
30342         ret_ref |= 1;
30343 }
30344         return ret_ref;
30345 }
30346 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
30347         LDKUpdateFee arg_conv;
30348         arg_conv.inner = (void*)(arg & (~1));
30349         arg_conv.is_owned = false;
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30351         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
30352         return ret_conv;
30353 }
30354
30355 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
30356         LDKUpdateFee orig_conv;
30357         orig_conv.inner = (void*)(orig & (~1));
30358         orig_conv.is_owned = false;
30359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30360         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
30361         uint32_t ret_ref = 0;
30362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30365         ret_ref = (uintptr_t)ret_var.inner;
30366         if (ret_var.is_owned) {
30367                 ret_ref |= 1;
30368         }
30369         return ret_ref;
30370 }
30371
30372 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
30373         LDKDataLossProtect this_obj_conv;
30374         this_obj_conv.inner = (void*)(this_obj & (~1));
30375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30377         DataLossProtect_free(this_obj_conv);
30378 }
30379
30380 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) {
30381         LDKDataLossProtect 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, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
30387         return ret_arr;
30388 }
30389
30390 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) {
30391         LDKDataLossProtect 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         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
30399 }
30400
30401 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) {
30402         LDKDataLossProtect this_ptr_conv;
30403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30404         this_ptr_conv.is_owned = false;
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30406         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30407         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30408         return ret_arr;
30409 }
30410
30411 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) {
30412         LDKDataLossProtect this_ptr_conv;
30413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30414         this_ptr_conv.is_owned = false;
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30416         LDKPublicKey val_ref;
30417         CHECK(val->arr_len == 33);
30418         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30419         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
30420 }
30421
30422 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) {
30423         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
30424         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
30425         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
30426         LDKPublicKey my_current_per_commitment_point_arg_ref;
30427         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
30428         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);
30429         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
30430         uint32_t ret_ref = 0;
30431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30434         ret_ref = (uintptr_t)ret_var.inner;
30435         if (ret_var.is_owned) {
30436                 ret_ref |= 1;
30437         }
30438         return ret_ref;
30439 }
30440
30441 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
30442         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
30443 uint32_t ret_ref = 0;
30444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30447 ret_ref = (uintptr_t)ret_var.inner;
30448 if (ret_var.is_owned) {
30449         ret_ref |= 1;
30450 }
30451         return ret_ref;
30452 }
30453 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
30454         LDKDataLossProtect arg_conv;
30455         arg_conv.inner = (void*)(arg & (~1));
30456         arg_conv.is_owned = false;
30457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30458         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
30459         return ret_conv;
30460 }
30461
30462 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
30463         LDKDataLossProtect orig_conv;
30464         orig_conv.inner = (void*)(orig & (~1));
30465         orig_conv.is_owned = false;
30466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30467         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
30468         uint32_t ret_ref = 0;
30469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30472         ret_ref = (uintptr_t)ret_var.inner;
30473         if (ret_var.is_owned) {
30474                 ret_ref |= 1;
30475         }
30476         return ret_ref;
30477 }
30478
30479 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
30480         LDKChannelReestablish this_obj_conv;
30481         this_obj_conv.inner = (void*)(this_obj & (~1));
30482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30484         ChannelReestablish_free(this_obj_conv);
30485 }
30486
30487 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
30488         LDKChannelReestablish 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30493         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
30494         return ret_arr;
30495 }
30496
30497 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30498         LDKChannelReestablish this_ptr_conv;
30499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30500         this_ptr_conv.is_owned = false;
30501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30502         LDKThirtyTwoBytes val_ref;
30503         CHECK(val->arr_len == 32);
30504         memcpy(val_ref.data, val->elems, 32); FREE(val);
30505         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
30506 }
30507
30508 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
30509         LDKChannelReestablish this_ptr_conv;
30510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30511         this_ptr_conv.is_owned = false;
30512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30513         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
30514         return ret_conv;
30515 }
30516
30517 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) {
30518         LDKChannelReestablish this_ptr_conv;
30519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30520         this_ptr_conv.is_owned = false;
30521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30522         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
30523 }
30524
30525 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
30526         LDKChannelReestablish this_ptr_conv;
30527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30528         this_ptr_conv.is_owned = false;
30529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30530         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
30531         return ret_conv;
30532 }
30533
30534 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) {
30535         LDKChannelReestablish this_ptr_conv;
30536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30537         this_ptr_conv.is_owned = false;
30538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30539         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
30540 }
30541
30542 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
30543         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
30544 uint32_t ret_ref = 0;
30545 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30546 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30547 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30548 ret_ref = (uintptr_t)ret_var.inner;
30549 if (ret_var.is_owned) {
30550         ret_ref |= 1;
30551 }
30552         return ret_ref;
30553 }
30554 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
30555         LDKChannelReestablish arg_conv;
30556         arg_conv.inner = (void*)(arg & (~1));
30557         arg_conv.is_owned = false;
30558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30559         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
30560         return ret_conv;
30561 }
30562
30563 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
30564         LDKChannelReestablish orig_conv;
30565         orig_conv.inner = (void*)(orig & (~1));
30566         orig_conv.is_owned = false;
30567         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30568         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
30569         uint32_t ret_ref = 0;
30570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30573         ret_ref = (uintptr_t)ret_var.inner;
30574         if (ret_var.is_owned) {
30575                 ret_ref |= 1;
30576         }
30577         return ret_ref;
30578 }
30579
30580 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
30581         LDKAnnouncementSignatures this_obj_conv;
30582         this_obj_conv.inner = (void*)(this_obj & (~1));
30583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30585         AnnouncementSignatures_free(this_obj_conv);
30586 }
30587
30588 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
30589         LDKAnnouncementSignatures 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30594         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
30595         return ret_arr;
30596 }
30597
30598 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30599         LDKAnnouncementSignatures this_ptr_conv;
30600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30601         this_ptr_conv.is_owned = false;
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30603         LDKThirtyTwoBytes val_ref;
30604         CHECK(val->arr_len == 32);
30605         memcpy(val_ref.data, val->elems, 32); FREE(val);
30606         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
30607 }
30608
30609 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
30610         LDKAnnouncementSignatures this_ptr_conv;
30611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30612         this_ptr_conv.is_owned = false;
30613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30614         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
30615         return ret_conv;
30616 }
30617
30618 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30619         LDKAnnouncementSignatures this_ptr_conv;
30620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30621         this_ptr_conv.is_owned = false;
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30623         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
30624 }
30625
30626 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
30627         LDKAnnouncementSignatures this_ptr_conv;
30628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30629         this_ptr_conv.is_owned = false;
30630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30631         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30632         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
30633         return ret_arr;
30634 }
30635
30636 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
30637         LDKAnnouncementSignatures this_ptr_conv;
30638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30639         this_ptr_conv.is_owned = false;
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30641         LDKSignature val_ref;
30642         CHECK(val->arr_len == 64);
30643         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30644         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
30645 }
30646
30647 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
30648         LDKAnnouncementSignatures this_ptr_conv;
30649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30650         this_ptr_conv.is_owned = false;
30651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30652         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30653         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
30654         return ret_arr;
30655 }
30656
30657 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
30658         LDKAnnouncementSignatures this_ptr_conv;
30659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30660         this_ptr_conv.is_owned = false;
30661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30662         LDKSignature val_ref;
30663         CHECK(val->arr_len == 64);
30664         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30665         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
30666 }
30667
30668 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) {
30669         LDKThirtyTwoBytes channel_id_arg_ref;
30670         CHECK(channel_id_arg->arr_len == 32);
30671         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30672         LDKSignature node_signature_arg_ref;
30673         CHECK(node_signature_arg->arr_len == 64);
30674         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
30675         LDKSignature bitcoin_signature_arg_ref;
30676         CHECK(bitcoin_signature_arg->arr_len == 64);
30677         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
30678         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
30679         uint32_t ret_ref = 0;
30680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30683         ret_ref = (uintptr_t)ret_var.inner;
30684         if (ret_var.is_owned) {
30685                 ret_ref |= 1;
30686         }
30687         return ret_ref;
30688 }
30689
30690 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
30691         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
30692 uint32_t ret_ref = 0;
30693 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30694 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30695 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30696 ret_ref = (uintptr_t)ret_var.inner;
30697 if (ret_var.is_owned) {
30698         ret_ref |= 1;
30699 }
30700         return ret_ref;
30701 }
30702 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
30703         LDKAnnouncementSignatures arg_conv;
30704         arg_conv.inner = (void*)(arg & (~1));
30705         arg_conv.is_owned = false;
30706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30707         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
30708         return ret_conv;
30709 }
30710
30711 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
30712         LDKAnnouncementSignatures orig_conv;
30713         orig_conv.inner = (void*)(orig & (~1));
30714         orig_conv.is_owned = false;
30715         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30716         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
30717         uint32_t ret_ref = 0;
30718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30721         ret_ref = (uintptr_t)ret_var.inner;
30722         if (ret_var.is_owned) {
30723                 ret_ref |= 1;
30724         }
30725         return ret_ref;
30726 }
30727
30728 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
30729         if ((this_ptr & 1) != 0) return;
30730         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30731         CHECK_ACCESS(this_ptr_ptr);
30732         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
30733         FREE((void*)this_ptr);
30734         NetAddress_free(this_ptr_conv);
30735 }
30736
30737 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
30738         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30739         *ret_copy = NetAddress_clone(arg);
30740 uint32_t ret_ref = (uintptr_t)ret_copy;
30741         return ret_ref;
30742 }
30743 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
30744         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
30745         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
30746         return ret_conv;
30747 }
30748
30749 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
30750         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
30751         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30752         *ret_copy = NetAddress_clone(orig_conv);
30753         uint32_t ret_ref = (uintptr_t)ret_copy;
30754         return ret_ref;
30755 }
30756
30757 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
30758         LDKFourBytes addr_ref;
30759         CHECK(addr->arr_len == 4);
30760         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
30761         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30762         *ret_copy = NetAddress_ipv4(addr_ref, port);
30763         uint32_t ret_ref = (uintptr_t)ret_copy;
30764         return ret_ref;
30765 }
30766
30767 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
30768         LDKSixteenBytes addr_ref;
30769         CHECK(addr->arr_len == 16);
30770         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
30771         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30772         *ret_copy = NetAddress_ipv6(addr_ref, port);
30773         uint32_t ret_ref = (uintptr_t)ret_copy;
30774         return ret_ref;
30775 }
30776
30777 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
30778         LDKTwelveBytes a_ref;
30779         CHECK(a->arr_len == 12);
30780         memcpy(a_ref.data, a->elems, 12); FREE(a);
30781         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30782         *ret_copy = NetAddress_onion_v2(a_ref);
30783         uint32_t ret_ref = (uintptr_t)ret_copy;
30784         return ret_ref;
30785 }
30786
30787 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) {
30788         LDKThirtyTwoBytes ed25519_pubkey_ref;
30789         CHECK(ed25519_pubkey->arr_len == 32);
30790         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
30791         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30792         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
30793         uint32_t ret_ref = (uintptr_t)ret_copy;
30794         return ret_ref;
30795 }
30796
30797 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
30798         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
30799         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
30800         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30801         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30802         CVec_u8Z_free(ret_var);
30803         return ret_arr;
30804 }
30805
30806 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
30807         LDKu8slice ser_ref;
30808         ser_ref.datalen = ser->arr_len;
30809         ser_ref.data = ser->elems;
30810         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
30811         *ret_conv = NetAddress_read(ser_ref);
30812         FREE(ser);
30813         return (uint32_t)ret_conv;
30814 }
30815
30816 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
30817         LDKUnsignedNodeAnnouncement this_obj_conv;
30818         this_obj_conv.inner = (void*)(this_obj & (~1));
30819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30821         UnsignedNodeAnnouncement_free(this_obj_conv);
30822 }
30823
30824 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
30825         LDKUnsignedNodeAnnouncement this_ptr_conv;
30826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30827         this_ptr_conv.is_owned = false;
30828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30829         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
30830         uint32_t ret_ref = 0;
30831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30834         ret_ref = (uintptr_t)ret_var.inner;
30835         if (ret_var.is_owned) {
30836                 ret_ref |= 1;
30837         }
30838         return ret_ref;
30839 }
30840
30841 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
30842         LDKUnsignedNodeAnnouncement this_ptr_conv;
30843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30844         this_ptr_conv.is_owned = false;
30845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30846         LDKNodeFeatures val_conv;
30847         val_conv.inner = (void*)(val & (~1));
30848         val_conv.is_owned = (val & 1) || (val == 0);
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30850         val_conv = NodeFeatures_clone(&val_conv);
30851         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
30852 }
30853
30854 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
30855         LDKUnsignedNodeAnnouncement this_ptr_conv;
30856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30857         this_ptr_conv.is_owned = false;
30858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30859         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
30860         return ret_conv;
30861 }
30862
30863 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
30864         LDKUnsignedNodeAnnouncement this_ptr_conv;
30865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30866         this_ptr_conv.is_owned = false;
30867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30868         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
30869 }
30870
30871 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
30872         LDKUnsignedNodeAnnouncement this_ptr_conv;
30873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30874         this_ptr_conv.is_owned = false;
30875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30876         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30877         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
30878         return ret_arr;
30879 }
30880
30881 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
30882         LDKUnsignedNodeAnnouncement this_ptr_conv;
30883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30884         this_ptr_conv.is_owned = false;
30885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30886         LDKPublicKey val_ref;
30887         CHECK(val->arr_len == 33);
30888         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30889         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
30890 }
30891
30892 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
30893         LDKUnsignedNodeAnnouncement this_ptr_conv;
30894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30895         this_ptr_conv.is_owned = false;
30896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30897         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
30898         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
30899         return ret_arr;
30900 }
30901
30902 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
30903         LDKUnsignedNodeAnnouncement this_ptr_conv;
30904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30905         this_ptr_conv.is_owned = false;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30907         LDKThreeBytes val_ref;
30908         CHECK(val->arr_len == 3);
30909         memcpy(val_ref.data, val->elems, 3); FREE(val);
30910         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
30911 }
30912
30913 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
30914         LDKUnsignedNodeAnnouncement this_ptr_conv;
30915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30916         this_ptr_conv.is_owned = false;
30917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30918         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30919         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
30920         return ret_arr;
30921 }
30922
30923 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
30924         LDKUnsignedNodeAnnouncement this_ptr_conv;
30925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30926         this_ptr_conv.is_owned = false;
30927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30928         LDKThirtyTwoBytes val_ref;
30929         CHECK(val->arr_len == 32);
30930         memcpy(val_ref.data, val->elems, 32); FREE(val);
30931         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
30932 }
30933
30934 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
30935         LDKUnsignedNodeAnnouncement this_ptr_conv;
30936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30937         this_ptr_conv.is_owned = false;
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30939         LDKCVec_NetAddressZ val_constr;
30940         val_constr.datalen = val->arr_len;
30941         if (val_constr.datalen > 0)
30942                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30943         else
30944                 val_constr.data = NULL;
30945         uint32_t* val_vals = val->elems;
30946         for (size_t m = 0; m < val_constr.datalen; m++) {
30947                 uint32_t val_conv_12 = val_vals[m];
30948                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
30949                 CHECK_ACCESS(val_conv_12_ptr);
30950                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
30951                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
30952                 val_constr.data[m] = val_conv_12_conv;
30953         }
30954         FREE(val);
30955         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
30956 }
30957
30958 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
30959         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
30960 uint32_t ret_ref = 0;
30961 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30962 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30963 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30964 ret_ref = (uintptr_t)ret_var.inner;
30965 if (ret_var.is_owned) {
30966         ret_ref |= 1;
30967 }
30968         return ret_ref;
30969 }
30970 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
30971         LDKUnsignedNodeAnnouncement arg_conv;
30972         arg_conv.inner = (void*)(arg & (~1));
30973         arg_conv.is_owned = false;
30974         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30975         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
30976         return ret_conv;
30977 }
30978
30979 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
30980         LDKUnsignedNodeAnnouncement orig_conv;
30981         orig_conv.inner = (void*)(orig & (~1));
30982         orig_conv.is_owned = false;
30983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30984         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
30985         uint32_t ret_ref = 0;
30986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30989         ret_ref = (uintptr_t)ret_var.inner;
30990         if (ret_var.is_owned) {
30991                 ret_ref |= 1;
30992         }
30993         return ret_ref;
30994 }
30995
30996 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
30997         LDKNodeAnnouncement this_obj_conv;
30998         this_obj_conv.inner = (void*)(this_obj & (~1));
30999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31001         NodeAnnouncement_free(this_obj_conv);
31002 }
31003
31004 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
31005         LDKNodeAnnouncement this_ptr_conv;
31006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31007         this_ptr_conv.is_owned = false;
31008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31009         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31010         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31011         return ret_arr;
31012 }
31013
31014 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
31015         LDKNodeAnnouncement this_ptr_conv;
31016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31017         this_ptr_conv.is_owned = false;
31018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31019         LDKSignature val_ref;
31020         CHECK(val->arr_len == 64);
31021         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31022         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31023 }
31024
31025 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
31026         LDKNodeAnnouncement this_ptr_conv;
31027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31028         this_ptr_conv.is_owned = false;
31029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31030         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31031         uint32_t ret_ref = 0;
31032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31035         ret_ref = (uintptr_t)ret_var.inner;
31036         if (ret_var.is_owned) {
31037                 ret_ref |= 1;
31038         }
31039         return ret_ref;
31040 }
31041
31042 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31043         LDKNodeAnnouncement this_ptr_conv;
31044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31045         this_ptr_conv.is_owned = false;
31046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31047         LDKUnsignedNodeAnnouncement val_conv;
31048         val_conv.inner = (void*)(val & (~1));
31049         val_conv.is_owned = (val & 1) || (val == 0);
31050         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31051         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31052         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31053 }
31054
31055 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
31056         LDKSignature signature_arg_ref;
31057         CHECK(signature_arg->arr_len == 64);
31058         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31059         LDKUnsignedNodeAnnouncement contents_arg_conv;
31060         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31061         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31062         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31063         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31064         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31065         uint32_t ret_ref = 0;
31066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31069         ret_ref = (uintptr_t)ret_var.inner;
31070         if (ret_var.is_owned) {
31071                 ret_ref |= 1;
31072         }
31073         return ret_ref;
31074 }
31075
31076 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31077         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31078 uint32_t ret_ref = 0;
31079 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31080 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31081 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31082 ret_ref = (uintptr_t)ret_var.inner;
31083 if (ret_var.is_owned) {
31084         ret_ref |= 1;
31085 }
31086         return ret_ref;
31087 }
31088 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
31089         LDKNodeAnnouncement arg_conv;
31090         arg_conv.inner = (void*)(arg & (~1));
31091         arg_conv.is_owned = false;
31092         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31093         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31094         return ret_conv;
31095 }
31096
31097 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
31098         LDKNodeAnnouncement orig_conv;
31099         orig_conv.inner = (void*)(orig & (~1));
31100         orig_conv.is_owned = false;
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31102         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31103         uint32_t ret_ref = 0;
31104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31107         ret_ref = (uintptr_t)ret_var.inner;
31108         if (ret_var.is_owned) {
31109                 ret_ref |= 1;
31110         }
31111         return ret_ref;
31112 }
31113
31114 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
31115         LDKUnsignedChannelAnnouncement this_obj_conv;
31116         this_obj_conv.inner = (void*)(this_obj & (~1));
31117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31119         UnsignedChannelAnnouncement_free(this_obj_conv);
31120 }
31121
31122 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
31123         LDKUnsignedChannelAnnouncement this_ptr_conv;
31124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31125         this_ptr_conv.is_owned = false;
31126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31127         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31128         uint32_t ret_ref = 0;
31129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31132         ret_ref = (uintptr_t)ret_var.inner;
31133         if (ret_var.is_owned) {
31134                 ret_ref |= 1;
31135         }
31136         return ret_ref;
31137 }
31138
31139 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31140         LDKUnsignedChannelAnnouncement this_ptr_conv;
31141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31142         this_ptr_conv.is_owned = false;
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31144         LDKChannelFeatures val_conv;
31145         val_conv.inner = (void*)(val & (~1));
31146         val_conv.is_owned = (val & 1) || (val == 0);
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31148         val_conv = ChannelFeatures_clone(&val_conv);
31149         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31150 }
31151
31152 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
31153         LDKUnsignedChannelAnnouncement this_ptr_conv;
31154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31155         this_ptr_conv.is_owned = false;
31156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31157         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31158         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31159         return ret_arr;
31160 }
31161
31162 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31163         LDKUnsignedChannelAnnouncement this_ptr_conv;
31164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31165         this_ptr_conv.is_owned = false;
31166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31167         LDKThirtyTwoBytes val_ref;
31168         CHECK(val->arr_len == 32);
31169         memcpy(val_ref.data, val->elems, 32); FREE(val);
31170         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31171 }
31172
31173 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
31174         LDKUnsignedChannelAnnouncement this_ptr_conv;
31175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31176         this_ptr_conv.is_owned = false;
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31178         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31179         return ret_conv;
31180 }
31181
31182 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31183         LDKUnsignedChannelAnnouncement this_ptr_conv;
31184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31185         this_ptr_conv.is_owned = false;
31186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31187         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31188 }
31189
31190 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
31191         LDKUnsignedChannelAnnouncement this_ptr_conv;
31192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31193         this_ptr_conv.is_owned = false;
31194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31195         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31196         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31197         return ret_arr;
31198 }
31199
31200 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
31201         LDKUnsignedChannelAnnouncement this_ptr_conv;
31202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31203         this_ptr_conv.is_owned = false;
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31205         LDKPublicKey val_ref;
31206         CHECK(val->arr_len == 33);
31207         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31208         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31209 }
31210
31211 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
31212         LDKUnsignedChannelAnnouncement this_ptr_conv;
31213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31214         this_ptr_conv.is_owned = false;
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31216         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31217         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31218         return ret_arr;
31219 }
31220
31221 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
31222         LDKUnsignedChannelAnnouncement this_ptr_conv;
31223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31224         this_ptr_conv.is_owned = false;
31225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31226         LDKPublicKey val_ref;
31227         CHECK(val->arr_len == 33);
31228         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31229         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31230 }
31231
31232 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
31233         LDKUnsignedChannelAnnouncement this_ptr_conv;
31234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31235         this_ptr_conv.is_owned = false;
31236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31237         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31238         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31239         return ret_arr;
31240 }
31241
31242 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
31243         LDKUnsignedChannelAnnouncement this_ptr_conv;
31244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31245         this_ptr_conv.is_owned = false;
31246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31247         LDKPublicKey val_ref;
31248         CHECK(val->arr_len == 33);
31249         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31250         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31251 }
31252
31253 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
31254         LDKUnsignedChannelAnnouncement this_ptr_conv;
31255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31256         this_ptr_conv.is_owned = false;
31257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31258         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31259         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31260         return ret_arr;
31261 }
31262
31263 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
31264         LDKUnsignedChannelAnnouncement this_ptr_conv;
31265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31266         this_ptr_conv.is_owned = false;
31267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31268         LDKPublicKey val_ref;
31269         CHECK(val->arr_len == 33);
31270         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31271         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31272 }
31273
31274 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31275         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31276 uint32_t ret_ref = 0;
31277 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31278 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31279 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31280 ret_ref = (uintptr_t)ret_var.inner;
31281 if (ret_var.is_owned) {
31282         ret_ref |= 1;
31283 }
31284         return ret_ref;
31285 }
31286 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
31287         LDKUnsignedChannelAnnouncement arg_conv;
31288         arg_conv.inner = (void*)(arg & (~1));
31289         arg_conv.is_owned = false;
31290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31291         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
31292         return ret_conv;
31293 }
31294
31295 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
31296         LDKUnsignedChannelAnnouncement orig_conv;
31297         orig_conv.inner = (void*)(orig & (~1));
31298         orig_conv.is_owned = false;
31299         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31300         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
31301         uint32_t ret_ref = 0;
31302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31305         ret_ref = (uintptr_t)ret_var.inner;
31306         if (ret_var.is_owned) {
31307                 ret_ref |= 1;
31308         }
31309         return ret_ref;
31310 }
31311
31312 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
31313         LDKChannelAnnouncement this_obj_conv;
31314         this_obj_conv.inner = (void*)(this_obj & (~1));
31315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31317         ChannelAnnouncement_free(this_obj_conv);
31318 }
31319
31320 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
31321         LDKChannelAnnouncement this_ptr_conv;
31322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31323         this_ptr_conv.is_owned = false;
31324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31325         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31326         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
31327         return ret_arr;
31328 }
31329
31330 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
31331         LDKChannelAnnouncement this_ptr_conv;
31332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31333         this_ptr_conv.is_owned = false;
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31335         LDKSignature val_ref;
31336         CHECK(val->arr_len == 64);
31337         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31338         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
31339 }
31340
31341 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
31342         LDKChannelAnnouncement this_ptr_conv;
31343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31344         this_ptr_conv.is_owned = false;
31345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31346         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31347         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
31348         return ret_arr;
31349 }
31350
31351 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
31352         LDKChannelAnnouncement this_ptr_conv;
31353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31354         this_ptr_conv.is_owned = false;
31355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31356         LDKSignature val_ref;
31357         CHECK(val->arr_len == 64);
31358         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31359         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
31360 }
31361
31362 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
31363         LDKChannelAnnouncement this_ptr_conv;
31364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31365         this_ptr_conv.is_owned = false;
31366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31367         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31368         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
31369         return ret_arr;
31370 }
31371
31372 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
31373         LDKChannelAnnouncement this_ptr_conv;
31374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31375         this_ptr_conv.is_owned = false;
31376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31377         LDKSignature val_ref;
31378         CHECK(val->arr_len == 64);
31379         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31380         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
31381 }
31382
31383 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
31384         LDKChannelAnnouncement this_ptr_conv;
31385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31386         this_ptr_conv.is_owned = false;
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31388         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31389         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
31390         return ret_arr;
31391 }
31392
31393 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
31394         LDKChannelAnnouncement this_ptr_conv;
31395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31396         this_ptr_conv.is_owned = false;
31397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31398         LDKSignature val_ref;
31399         CHECK(val->arr_len == 64);
31400         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31401         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
31402 }
31403
31404 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
31405         LDKChannelAnnouncement this_ptr_conv;
31406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31407         this_ptr_conv.is_owned = false;
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31409         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
31410         uint32_t ret_ref = 0;
31411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31414         ret_ref = (uintptr_t)ret_var.inner;
31415         if (ret_var.is_owned) {
31416                 ret_ref |= 1;
31417         }
31418         return ret_ref;
31419 }
31420
31421 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31422         LDKChannelAnnouncement this_ptr_conv;
31423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31424         this_ptr_conv.is_owned = false;
31425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31426         LDKUnsignedChannelAnnouncement val_conv;
31427         val_conv.inner = (void*)(val & (~1));
31428         val_conv.is_owned = (val & 1) || (val == 0);
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31430         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
31431         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
31432 }
31433
31434 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) {
31435         LDKSignature node_signature_1_arg_ref;
31436         CHECK(node_signature_1_arg->arr_len == 64);
31437         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
31438         LDKSignature node_signature_2_arg_ref;
31439         CHECK(node_signature_2_arg->arr_len == 64);
31440         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
31441         LDKSignature bitcoin_signature_1_arg_ref;
31442         CHECK(bitcoin_signature_1_arg->arr_len == 64);
31443         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
31444         LDKSignature bitcoin_signature_2_arg_ref;
31445         CHECK(bitcoin_signature_2_arg->arr_len == 64);
31446         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
31447         LDKUnsignedChannelAnnouncement contents_arg_conv;
31448         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31449         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31450         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31451         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
31452         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);
31453         uint32_t ret_ref = 0;
31454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31457         ret_ref = (uintptr_t)ret_var.inner;
31458         if (ret_var.is_owned) {
31459                 ret_ref |= 1;
31460         }
31461         return ret_ref;
31462 }
31463
31464 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
31465         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
31466 uint32_t ret_ref = 0;
31467 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31468 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31469 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31470 ret_ref = (uintptr_t)ret_var.inner;
31471 if (ret_var.is_owned) {
31472         ret_ref |= 1;
31473 }
31474         return ret_ref;
31475 }
31476 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
31477         LDKChannelAnnouncement arg_conv;
31478         arg_conv.inner = (void*)(arg & (~1));
31479         arg_conv.is_owned = false;
31480         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31481         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
31482         return ret_conv;
31483 }
31484
31485 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
31486         LDKChannelAnnouncement orig_conv;
31487         orig_conv.inner = (void*)(orig & (~1));
31488         orig_conv.is_owned = false;
31489         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31490         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
31491         uint32_t ret_ref = 0;
31492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31495         ret_ref = (uintptr_t)ret_var.inner;
31496         if (ret_var.is_owned) {
31497                 ret_ref |= 1;
31498         }
31499         return ret_ref;
31500 }
31501
31502 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
31503         LDKUnsignedChannelUpdate this_obj_conv;
31504         this_obj_conv.inner = (void*)(this_obj & (~1));
31505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31507         UnsignedChannelUpdate_free(this_obj_conv);
31508 }
31509
31510 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
31511         LDKUnsignedChannelUpdate this_ptr_conv;
31512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31513         this_ptr_conv.is_owned = false;
31514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31515         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31516         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
31517         return ret_arr;
31518 }
31519
31520 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31521         LDKUnsignedChannelUpdate this_ptr_conv;
31522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31523         this_ptr_conv.is_owned = false;
31524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31525         LDKThirtyTwoBytes val_ref;
31526         CHECK(val->arr_len == 32);
31527         memcpy(val_ref.data, val->elems, 32); FREE(val);
31528         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
31529 }
31530
31531 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
31532         LDKUnsignedChannelUpdate this_ptr_conv;
31533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31534         this_ptr_conv.is_owned = false;
31535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31536         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
31537         return ret_conv;
31538 }
31539
31540 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31541         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
31546 }
31547
31548 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
31549         LDKUnsignedChannelUpdate this_ptr_conv;
31550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31551         this_ptr_conv.is_owned = false;
31552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31553         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
31554         return ret_conv;
31555 }
31556
31557 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
31558         LDKUnsignedChannelUpdate this_ptr_conv;
31559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31560         this_ptr_conv.is_owned = false;
31561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31562         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
31563 }
31564
31565 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
31566         LDKUnsignedChannelUpdate this_ptr_conv;
31567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31568         this_ptr_conv.is_owned = false;
31569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31570         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
31571         return ret_conv;
31572 }
31573
31574 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
31575         LDKUnsignedChannelUpdate this_ptr_conv;
31576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31577         this_ptr_conv.is_owned = false;
31578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31579         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
31580 }
31581
31582 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
31583         LDKUnsignedChannelUpdate 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         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31588         return ret_conv;
31589 }
31590
31591 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
31592         LDKUnsignedChannelUpdate this_ptr_conv;
31593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31594         this_ptr_conv.is_owned = false;
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31596         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
31597 }
31598
31599 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
31600         LDKUnsignedChannelUpdate this_ptr_conv;
31601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31602         this_ptr_conv.is_owned = false;
31603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31604         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
31605         return ret_conv;
31606 }
31607
31608 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
31609         LDKUnsignedChannelUpdate this_ptr_conv;
31610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31611         this_ptr_conv.is_owned = false;
31612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31613         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
31614 }
31615
31616 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
31617         LDKUnsignedChannelUpdate this_ptr_conv;
31618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31619         this_ptr_conv.is_owned = false;
31620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31621         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
31622         return ret_conv;
31623 }
31624
31625 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
31626         LDKUnsignedChannelUpdate this_ptr_conv;
31627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31628         this_ptr_conv.is_owned = false;
31629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31630         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
31631 }
31632
31633 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
31634         LDKUnsignedChannelUpdate this_ptr_conv;
31635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31636         this_ptr_conv.is_owned = false;
31637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31638         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
31639         return ret_conv;
31640 }
31641
31642 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
31643         LDKUnsignedChannelUpdate this_ptr_conv;
31644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31645         this_ptr_conv.is_owned = false;
31646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31647         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
31648 }
31649
31650 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
31651         LDKUnsignedChannelUpdate this_ptr_conv;
31652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31653         this_ptr_conv.is_owned = false;
31654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31655         LDKCVec_u8Z val_ref;
31656         val_ref.datalen = val->arr_len;
31657         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31658         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
31659         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
31660 }
31661
31662 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
31663         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
31664 uint32_t ret_ref = 0;
31665 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31666 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31667 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31668 ret_ref = (uintptr_t)ret_var.inner;
31669 if (ret_var.is_owned) {
31670         ret_ref |= 1;
31671 }
31672         return ret_ref;
31673 }
31674 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
31675         LDKUnsignedChannelUpdate arg_conv;
31676         arg_conv.inner = (void*)(arg & (~1));
31677         arg_conv.is_owned = false;
31678         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31679         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
31680         return ret_conv;
31681 }
31682
31683 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
31684         LDKUnsignedChannelUpdate orig_conv;
31685         orig_conv.inner = (void*)(orig & (~1));
31686         orig_conv.is_owned = false;
31687         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31688         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
31689         uint32_t ret_ref = 0;
31690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31693         ret_ref = (uintptr_t)ret_var.inner;
31694         if (ret_var.is_owned) {
31695                 ret_ref |= 1;
31696         }
31697         return ret_ref;
31698 }
31699
31700 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
31701         LDKChannelUpdate this_obj_conv;
31702         this_obj_conv.inner = (void*)(this_obj & (~1));
31703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31705         ChannelUpdate_free(this_obj_conv);
31706 }
31707
31708 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
31709         LDKChannelUpdate this_ptr_conv;
31710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31711         this_ptr_conv.is_owned = false;
31712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31713         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31714         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
31715         return ret_arr;
31716 }
31717
31718 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
31719         LDKChannelUpdate this_ptr_conv;
31720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31721         this_ptr_conv.is_owned = false;
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31723         LDKSignature val_ref;
31724         CHECK(val->arr_len == 64);
31725         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31726         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
31727 }
31728
31729 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
31730         LDKChannelUpdate this_ptr_conv;
31731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31732         this_ptr_conv.is_owned = false;
31733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31734         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
31735         uint32_t ret_ref = 0;
31736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31739         ret_ref = (uintptr_t)ret_var.inner;
31740         if (ret_var.is_owned) {
31741                 ret_ref |= 1;
31742         }
31743         return ret_ref;
31744 }
31745
31746 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
31747         LDKChannelUpdate this_ptr_conv;
31748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31749         this_ptr_conv.is_owned = false;
31750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31751         LDKUnsignedChannelUpdate val_conv;
31752         val_conv.inner = (void*)(val & (~1));
31753         val_conv.is_owned = (val & 1) || (val == 0);
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31755         val_conv = UnsignedChannelUpdate_clone(&val_conv);
31756         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
31757 }
31758
31759 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
31760         LDKSignature signature_arg_ref;
31761         CHECK(signature_arg->arr_len == 64);
31762         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31763         LDKUnsignedChannelUpdate contents_arg_conv;
31764         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31765         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31766         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31767         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
31768         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
31769         uint32_t ret_ref = 0;
31770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31773         ret_ref = (uintptr_t)ret_var.inner;
31774         if (ret_var.is_owned) {
31775                 ret_ref |= 1;
31776         }
31777         return ret_ref;
31778 }
31779
31780 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
31781         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
31782 uint32_t ret_ref = 0;
31783 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31784 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31785 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31786 ret_ref = (uintptr_t)ret_var.inner;
31787 if (ret_var.is_owned) {
31788         ret_ref |= 1;
31789 }
31790         return ret_ref;
31791 }
31792 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
31793         LDKChannelUpdate arg_conv;
31794         arg_conv.inner = (void*)(arg & (~1));
31795         arg_conv.is_owned = false;
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31797         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
31798         return ret_conv;
31799 }
31800
31801 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
31802         LDKChannelUpdate orig_conv;
31803         orig_conv.inner = (void*)(orig & (~1));
31804         orig_conv.is_owned = false;
31805         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31806         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
31807         uint32_t ret_ref = 0;
31808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31811         ret_ref = (uintptr_t)ret_var.inner;
31812         if (ret_var.is_owned) {
31813                 ret_ref |= 1;
31814         }
31815         return ret_ref;
31816 }
31817
31818 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
31819         LDKQueryChannelRange this_obj_conv;
31820         this_obj_conv.inner = (void*)(this_obj & (~1));
31821         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31823         QueryChannelRange_free(this_obj_conv);
31824 }
31825
31826 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
31827         LDKQueryChannelRange this_ptr_conv;
31828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31829         this_ptr_conv.is_owned = false;
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31831         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31832         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
31833         return ret_arr;
31834 }
31835
31836 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31837         LDKQueryChannelRange this_ptr_conv;
31838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31839         this_ptr_conv.is_owned = false;
31840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31841         LDKThirtyTwoBytes val_ref;
31842         CHECK(val->arr_len == 32);
31843         memcpy(val_ref.data, val->elems, 32); FREE(val);
31844         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31845 }
31846
31847 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
31848         LDKQueryChannelRange this_ptr_conv;
31849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31850         this_ptr_conv.is_owned = false;
31851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31852         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
31853         return ret_conv;
31854 }
31855
31856 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31857         LDKQueryChannelRange this_ptr_conv;
31858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31859         this_ptr_conv.is_owned = false;
31860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31861         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
31862 }
31863
31864 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31865         LDKQueryChannelRange this_ptr_conv;
31866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31867         this_ptr_conv.is_owned = false;
31868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31869         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
31870         return ret_conv;
31871 }
31872
31873 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31874         LDKQueryChannelRange this_ptr_conv;
31875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31876         this_ptr_conv.is_owned = false;
31877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31878         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31879 }
31880
31881 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) {
31882         LDKThirtyTwoBytes chain_hash_arg_ref;
31883         CHECK(chain_hash_arg->arr_len == 32);
31884         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31885         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
31886         uint32_t ret_ref = 0;
31887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31890         ret_ref = (uintptr_t)ret_var.inner;
31891         if (ret_var.is_owned) {
31892                 ret_ref |= 1;
31893         }
31894         return ret_ref;
31895 }
31896
31897 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
31898         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
31899 uint32_t ret_ref = 0;
31900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31903 ret_ref = (uintptr_t)ret_var.inner;
31904 if (ret_var.is_owned) {
31905         ret_ref |= 1;
31906 }
31907         return ret_ref;
31908 }
31909 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
31910         LDKQueryChannelRange arg_conv;
31911         arg_conv.inner = (void*)(arg & (~1));
31912         arg_conv.is_owned = false;
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31914         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
31915         return ret_conv;
31916 }
31917
31918 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
31919         LDKQueryChannelRange orig_conv;
31920         orig_conv.inner = (void*)(orig & (~1));
31921         orig_conv.is_owned = false;
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31923         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
31924         uint32_t ret_ref = 0;
31925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31928         ret_ref = (uintptr_t)ret_var.inner;
31929         if (ret_var.is_owned) {
31930                 ret_ref |= 1;
31931         }
31932         return ret_ref;
31933 }
31934
31935 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
31936         LDKReplyChannelRange this_obj_conv;
31937         this_obj_conv.inner = (void*)(this_obj & (~1));
31938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31940         ReplyChannelRange_free(this_obj_conv);
31941 }
31942
31943 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
31944         LDKReplyChannelRange this_ptr_conv;
31945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31946         this_ptr_conv.is_owned = false;
31947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31948         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31949         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
31950         return ret_arr;
31951 }
31952
31953 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31954         LDKReplyChannelRange this_ptr_conv;
31955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31956         this_ptr_conv.is_owned = false;
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31958         LDKThirtyTwoBytes val_ref;
31959         CHECK(val->arr_len == 32);
31960         memcpy(val_ref.data, val->elems, 32); FREE(val);
31961         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31962 }
31963
31964 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
31965         LDKReplyChannelRange this_ptr_conv;
31966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31967         this_ptr_conv.is_owned = false;
31968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31969         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
31970         return ret_conv;
31971 }
31972
31973 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31974         LDKReplyChannelRange this_ptr_conv;
31975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31976         this_ptr_conv.is_owned = false;
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31978         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
31979 }
31980
31981 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31982         LDKReplyChannelRange this_ptr_conv;
31983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31984         this_ptr_conv.is_owned = false;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31986         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
31987         return ret_conv;
31988 }
31989
31990 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31991         LDKReplyChannelRange this_ptr_conv;
31992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31993         this_ptr_conv.is_owned = false;
31994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31995         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31996 }
31997
31998 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
31999         LDKReplyChannelRange this_ptr_conv;
32000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32001         this_ptr_conv.is_owned = false;
32002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32003         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32004         return ret_conv;
32005 }
32006
32007 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
32008         LDKReplyChannelRange this_ptr_conv;
32009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32010         this_ptr_conv.is_owned = false;
32011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32012         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32013 }
32014
32015 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32016         LDKReplyChannelRange this_ptr_conv;
32017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32018         this_ptr_conv.is_owned = false;
32019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32020         LDKCVec_u64Z val_constr;
32021         val_constr.datalen = val->arr_len;
32022         if (val_constr.datalen > 0)
32023                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32024         else
32025                 val_constr.data = NULL;
32026         int64_t* val_vals = val->elems;
32027         for (size_t i = 0; i < val_constr.datalen; i++) {
32028                 int64_t val_conv_8 = val_vals[i];
32029                 val_constr.data[i] = val_conv_8;
32030         }
32031         FREE(val);
32032         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32033 }
32034
32035 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) {
32036         LDKThirtyTwoBytes chain_hash_arg_ref;
32037         CHECK(chain_hash_arg->arr_len == 32);
32038         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32039         LDKCVec_u64Z short_channel_ids_arg_constr;
32040         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32041         if (short_channel_ids_arg_constr.datalen > 0)
32042                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32043         else
32044                 short_channel_ids_arg_constr.data = NULL;
32045         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32046         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32047                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32048                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32049         }
32050         FREE(short_channel_ids_arg);
32051         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
32052         uint32_t ret_ref = 0;
32053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32056         ret_ref = (uintptr_t)ret_var.inner;
32057         if (ret_var.is_owned) {
32058                 ret_ref |= 1;
32059         }
32060         return ret_ref;
32061 }
32062
32063 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32064         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
32065 uint32_t ret_ref = 0;
32066 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32067 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32068 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32069 ret_ref = (uintptr_t)ret_var.inner;
32070 if (ret_var.is_owned) {
32071         ret_ref |= 1;
32072 }
32073         return ret_ref;
32074 }
32075 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
32076         LDKReplyChannelRange arg_conv;
32077         arg_conv.inner = (void*)(arg & (~1));
32078         arg_conv.is_owned = false;
32079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32080         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32081         return ret_conv;
32082 }
32083
32084 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
32085         LDKReplyChannelRange orig_conv;
32086         orig_conv.inner = (void*)(orig & (~1));
32087         orig_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32089         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
32090         uint32_t ret_ref = 0;
32091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32094         ret_ref = (uintptr_t)ret_var.inner;
32095         if (ret_var.is_owned) {
32096                 ret_ref |= 1;
32097         }
32098         return ret_ref;
32099 }
32100
32101 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
32102         LDKQueryShortChannelIds this_obj_conv;
32103         this_obj_conv.inner = (void*)(this_obj & (~1));
32104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32106         QueryShortChannelIds_free(this_obj_conv);
32107 }
32108
32109 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
32110         LDKQueryShortChannelIds this_ptr_conv;
32111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32112         this_ptr_conv.is_owned = false;
32113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32114         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32115         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32116         return ret_arr;
32117 }
32118
32119 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32120         LDKQueryShortChannelIds this_ptr_conv;
32121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32122         this_ptr_conv.is_owned = false;
32123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32124         LDKThirtyTwoBytes val_ref;
32125         CHECK(val->arr_len == 32);
32126         memcpy(val_ref.data, val->elems, 32); FREE(val);
32127         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32128 }
32129
32130 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32131         LDKQueryShortChannelIds this_ptr_conv;
32132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32133         this_ptr_conv.is_owned = false;
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32135         LDKCVec_u64Z val_constr;
32136         val_constr.datalen = val->arr_len;
32137         if (val_constr.datalen > 0)
32138                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32139         else
32140                 val_constr.data = NULL;
32141         int64_t* val_vals = val->elems;
32142         for (size_t i = 0; i < val_constr.datalen; i++) {
32143                 int64_t val_conv_8 = val_vals[i];
32144                 val_constr.data[i] = val_conv_8;
32145         }
32146         FREE(val);
32147         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32148 }
32149
32150 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32151         LDKThirtyTwoBytes chain_hash_arg_ref;
32152         CHECK(chain_hash_arg->arr_len == 32);
32153         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32154         LDKCVec_u64Z short_channel_ids_arg_constr;
32155         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32156         if (short_channel_ids_arg_constr.datalen > 0)
32157                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32158         else
32159                 short_channel_ids_arg_constr.data = NULL;
32160         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32161         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32162                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32163                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32164         }
32165         FREE(short_channel_ids_arg);
32166         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32167         uint32_t ret_ref = 0;
32168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32171         ret_ref = (uintptr_t)ret_var.inner;
32172         if (ret_var.is_owned) {
32173                 ret_ref |= 1;
32174         }
32175         return ret_ref;
32176 }
32177
32178 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32179         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32180 uint32_t ret_ref = 0;
32181 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32182 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32183 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32184 ret_ref = (uintptr_t)ret_var.inner;
32185 if (ret_var.is_owned) {
32186         ret_ref |= 1;
32187 }
32188         return ret_ref;
32189 }
32190 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
32191         LDKQueryShortChannelIds arg_conv;
32192         arg_conv.inner = (void*)(arg & (~1));
32193         arg_conv.is_owned = false;
32194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32195         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
32196         return ret_conv;
32197 }
32198
32199 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
32200         LDKQueryShortChannelIds orig_conv;
32201         orig_conv.inner = (void*)(orig & (~1));
32202         orig_conv.is_owned = false;
32203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32204         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
32205         uint32_t ret_ref = 0;
32206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32209         ret_ref = (uintptr_t)ret_var.inner;
32210         if (ret_var.is_owned) {
32211                 ret_ref |= 1;
32212         }
32213         return ret_ref;
32214 }
32215
32216 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
32217         LDKReplyShortChannelIdsEnd this_obj_conv;
32218         this_obj_conv.inner = (void*)(this_obj & (~1));
32219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32221         ReplyShortChannelIdsEnd_free(this_obj_conv);
32222 }
32223
32224 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
32225         LDKReplyShortChannelIdsEnd 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_tArray ret_arr = init_int8_tArray(32, __LINE__);
32230         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
32231         return ret_arr;
32232 }
32233
32234 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32235         LDKReplyShortChannelIdsEnd this_ptr_conv;
32236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32237         this_ptr_conv.is_owned = false;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32239         LDKThirtyTwoBytes val_ref;
32240         CHECK(val->arr_len == 32);
32241         memcpy(val_ref.data, val->elems, 32); FREE(val);
32242         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
32243 }
32244
32245 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
32246         LDKReplyShortChannelIdsEnd this_ptr_conv;
32247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32248         this_ptr_conv.is_owned = false;
32249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32250         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
32251         return ret_conv;
32252 }
32253
32254 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
32255         LDKReplyShortChannelIdsEnd this_ptr_conv;
32256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32257         this_ptr_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32259         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
32260 }
32261
32262 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
32263         LDKThirtyTwoBytes chain_hash_arg_ref;
32264         CHECK(chain_hash_arg->arr_len == 32);
32265         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32266         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
32267         uint32_t ret_ref = 0;
32268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32271         ret_ref = (uintptr_t)ret_var.inner;
32272         if (ret_var.is_owned) {
32273                 ret_ref |= 1;
32274         }
32275         return ret_ref;
32276 }
32277
32278 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
32279         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
32280 uint32_t ret_ref = 0;
32281 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32282 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32283 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32284 ret_ref = (uintptr_t)ret_var.inner;
32285 if (ret_var.is_owned) {
32286         ret_ref |= 1;
32287 }
32288         return ret_ref;
32289 }
32290 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
32291         LDKReplyShortChannelIdsEnd arg_conv;
32292         arg_conv.inner = (void*)(arg & (~1));
32293         arg_conv.is_owned = false;
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32295         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
32296         return ret_conv;
32297 }
32298
32299 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
32300         LDKReplyShortChannelIdsEnd orig_conv;
32301         orig_conv.inner = (void*)(orig & (~1));
32302         orig_conv.is_owned = false;
32303         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32304         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
32305         uint32_t ret_ref = 0;
32306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32309         ret_ref = (uintptr_t)ret_var.inner;
32310         if (ret_var.is_owned) {
32311                 ret_ref |= 1;
32312         }
32313         return ret_ref;
32314 }
32315
32316 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
32317         LDKGossipTimestampFilter this_obj_conv;
32318         this_obj_conv.inner = (void*)(this_obj & (~1));
32319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32321         GossipTimestampFilter_free(this_obj_conv);
32322 }
32323
32324 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
32325         LDKGossipTimestampFilter this_ptr_conv;
32326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32327         this_ptr_conv.is_owned = false;
32328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32329         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32330         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
32331         return ret_arr;
32332 }
32333
32334 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32335         LDKGossipTimestampFilter this_ptr_conv;
32336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32337         this_ptr_conv.is_owned = false;
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32339         LDKThirtyTwoBytes val_ref;
32340         CHECK(val->arr_len == 32);
32341         memcpy(val_ref.data, val->elems, 32); FREE(val);
32342         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
32343 }
32344
32345 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
32346         LDKGossipTimestampFilter this_ptr_conv;
32347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32348         this_ptr_conv.is_owned = false;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32350         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
32351         return ret_conv;
32352 }
32353
32354 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
32355         LDKGossipTimestampFilter this_ptr_conv;
32356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32357         this_ptr_conv.is_owned = false;
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32359         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
32360 }
32361
32362 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
32363         LDKGossipTimestampFilter this_ptr_conv;
32364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32365         this_ptr_conv.is_owned = false;
32366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32367         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
32368         return ret_conv;
32369 }
32370
32371 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
32372         LDKGossipTimestampFilter this_ptr_conv;
32373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32374         this_ptr_conv.is_owned = false;
32375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32376         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
32377 }
32378
32379 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) {
32380         LDKThirtyTwoBytes chain_hash_arg_ref;
32381         CHECK(chain_hash_arg->arr_len == 32);
32382         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32383         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
32384         uint32_t ret_ref = 0;
32385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32388         ret_ref = (uintptr_t)ret_var.inner;
32389         if (ret_var.is_owned) {
32390                 ret_ref |= 1;
32391         }
32392         return ret_ref;
32393 }
32394
32395 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
32396         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
32397 uint32_t ret_ref = 0;
32398 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32399 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32400 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32401 ret_ref = (uintptr_t)ret_var.inner;
32402 if (ret_var.is_owned) {
32403         ret_ref |= 1;
32404 }
32405         return ret_ref;
32406 }
32407 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
32408         LDKGossipTimestampFilter arg_conv;
32409         arg_conv.inner = (void*)(arg & (~1));
32410         arg_conv.is_owned = false;
32411         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32412         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
32413         return ret_conv;
32414 }
32415
32416 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
32417         LDKGossipTimestampFilter orig_conv;
32418         orig_conv.inner = (void*)(orig & (~1));
32419         orig_conv.is_owned = false;
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32421         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
32422         uint32_t ret_ref = 0;
32423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32426         ret_ref = (uintptr_t)ret_var.inner;
32427         if (ret_var.is_owned) {
32428                 ret_ref |= 1;
32429         }
32430         return ret_ref;
32431 }
32432
32433 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
32434         if ((this_ptr & 1) != 0) return;
32435         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32436         CHECK_ACCESS(this_ptr_ptr);
32437         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
32438         FREE((void*)this_ptr);
32439         ErrorAction_free(this_ptr_conv);
32440 }
32441
32442 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
32443         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32444         *ret_copy = ErrorAction_clone(arg);
32445 uint32_t ret_ref = (uintptr_t)ret_copy;
32446         return ret_ref;
32447 }
32448 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
32449         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
32450         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
32451         return ret_conv;
32452 }
32453
32454 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
32455         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
32456         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32457         *ret_copy = ErrorAction_clone(orig_conv);
32458         uint32_t ret_ref = (uintptr_t)ret_copy;
32459         return ret_ref;
32460 }
32461
32462 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
32463         LDKErrorMessage msg_conv;
32464         msg_conv.inner = (void*)(msg & (~1));
32465         msg_conv.is_owned = (msg & 1) || (msg == 0);
32466         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32467         msg_conv = ErrorMessage_clone(&msg_conv);
32468         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32469         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
32470         uint32_t ret_ref = (uintptr_t)ret_copy;
32471         return ret_ref;
32472 }
32473
32474 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
32475         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32476         *ret_copy = ErrorAction_ignore_error();
32477         uint32_t ret_ref = (uintptr_t)ret_copy;
32478         return ret_ref;
32479 }
32480
32481 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
32482         LDKLevel a_conv = LDKLevel_from_js(a);
32483         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32484         *ret_copy = ErrorAction_ignore_and_log(a_conv);
32485         uint32_t ret_ref = (uintptr_t)ret_copy;
32486         return ret_ref;
32487 }
32488
32489 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
32490         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32491         *ret_copy = ErrorAction_ignore_duplicate_gossip();
32492         uint32_t ret_ref = (uintptr_t)ret_copy;
32493         return ret_ref;
32494 }
32495
32496 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
32497         LDKErrorMessage msg_conv;
32498         msg_conv.inner = (void*)(msg & (~1));
32499         msg_conv.is_owned = (msg & 1) || (msg == 0);
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32501         msg_conv = ErrorMessage_clone(&msg_conv);
32502         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32503         *ret_copy = ErrorAction_send_error_message(msg_conv);
32504         uint32_t ret_ref = (uintptr_t)ret_copy;
32505         return ret_ref;
32506 }
32507
32508 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
32509         LDKWarningMessage msg_conv;
32510         msg_conv.inner = (void*)(msg & (~1));
32511         msg_conv.is_owned = (msg & 1) || (msg == 0);
32512         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32513         msg_conv = WarningMessage_clone(&msg_conv);
32514         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
32515         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32516         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
32517         uint32_t ret_ref = (uintptr_t)ret_copy;
32518         return ret_ref;
32519 }
32520
32521 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
32522         LDKLightningError this_obj_conv;
32523         this_obj_conv.inner = (void*)(this_obj & (~1));
32524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32526         LightningError_free(this_obj_conv);
32527 }
32528
32529 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
32530         LDKLightningError this_ptr_conv;
32531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32532         this_ptr_conv.is_owned = false;
32533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32534         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
32535         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
32536         Str_free(ret_str);
32537         return ret_conv;
32538 }
32539
32540 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
32541         LDKLightningError this_ptr_conv;
32542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32543         this_ptr_conv.is_owned = false;
32544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32545         LDKStr val_conv = str_ref_to_owned_c(val);
32546         LightningError_set_err(&this_ptr_conv, val_conv);
32547 }
32548
32549 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
32550         LDKLightningError this_ptr_conv;
32551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32552         this_ptr_conv.is_owned = false;
32553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32554         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32555         *ret_copy = LightningError_get_action(&this_ptr_conv);
32556         uint32_t ret_ref = (uintptr_t)ret_copy;
32557         return ret_ref;
32558 }
32559
32560 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
32561         LDKLightningError 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         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32566         CHECK_ACCESS(val_ptr);
32567         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
32568         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
32569         LightningError_set_action(&this_ptr_conv, val_conv);
32570 }
32571
32572 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
32573         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
32574         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
32575         CHECK_ACCESS(action_arg_ptr);
32576         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
32577         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
32578         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
32579         uint32_t ret_ref = 0;
32580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32583         ret_ref = (uintptr_t)ret_var.inner;
32584         if (ret_var.is_owned) {
32585                 ret_ref |= 1;
32586         }
32587         return ret_ref;
32588 }
32589
32590 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
32591         LDKLightningError ret_var = LightningError_clone(arg);
32592 uint32_t ret_ref = 0;
32593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32596 ret_ref = (uintptr_t)ret_var.inner;
32597 if (ret_var.is_owned) {
32598         ret_ref |= 1;
32599 }
32600         return ret_ref;
32601 }
32602 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
32603         LDKLightningError arg_conv;
32604         arg_conv.inner = (void*)(arg & (~1));
32605         arg_conv.is_owned = false;
32606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32607         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
32608         return ret_conv;
32609 }
32610
32611 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
32612         LDKLightningError orig_conv;
32613         orig_conv.inner = (void*)(orig & (~1));
32614         orig_conv.is_owned = false;
32615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32616         LDKLightningError ret_var = LightningError_clone(&orig_conv);
32617         uint32_t ret_ref = 0;
32618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32621         ret_ref = (uintptr_t)ret_var.inner;
32622         if (ret_var.is_owned) {
32623                 ret_ref |= 1;
32624         }
32625         return ret_ref;
32626 }
32627
32628 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
32629         LDKCommitmentUpdate this_obj_conv;
32630         this_obj_conv.inner = (void*)(this_obj & (~1));
32631         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32633         CommitmentUpdate_free(this_obj_conv);
32634 }
32635
32636 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
32637         LDKCommitmentUpdate this_ptr_conv;
32638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32639         this_ptr_conv.is_owned = false;
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32641         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
32642         uint32_tArray ret_arr = NULL;
32643         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32644         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32645         for (size_t p = 0; p < ret_var.datalen; p++) {
32646                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
32647                 uint32_t ret_conv_15_ref = 0;
32648                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32649                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32650                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
32651                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
32652                 if (ret_conv_15_var.is_owned) {
32653                         ret_conv_15_ref |= 1;
32654                 }
32655                 ret_arr_ptr[p] = ret_conv_15_ref;
32656         }
32657         
32658         FREE(ret_var.data);
32659         return ret_arr;
32660 }
32661
32662 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
32663         LDKCommitmentUpdate this_ptr_conv;
32664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32665         this_ptr_conv.is_owned = false;
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32667         LDKCVec_UpdateAddHTLCZ val_constr;
32668         val_constr.datalen = val->arr_len;
32669         if (val_constr.datalen > 0)
32670                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32671         else
32672                 val_constr.data = NULL;
32673         uint32_t* val_vals = val->elems;
32674         for (size_t p = 0; p < val_constr.datalen; p++) {
32675                 uint32_t val_conv_15 = val_vals[p];
32676                 LDKUpdateAddHTLC val_conv_15_conv;
32677                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
32678                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
32679                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
32680                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
32681                 val_constr.data[p] = val_conv_15_conv;
32682         }
32683         FREE(val);
32684         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
32685 }
32686
32687 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
32688         LDKCommitmentUpdate this_ptr_conv;
32689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32690         this_ptr_conv.is_owned = false;
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32692         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
32693         uint32_tArray ret_arr = NULL;
32694         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32695         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32696         for (size_t t = 0; t < ret_var.datalen; t++) {
32697                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
32698                 uint32_t ret_conv_19_ref = 0;
32699                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32700                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32701                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
32702                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
32703                 if (ret_conv_19_var.is_owned) {
32704                         ret_conv_19_ref |= 1;
32705                 }
32706                 ret_arr_ptr[t] = ret_conv_19_ref;
32707         }
32708         
32709         FREE(ret_var.data);
32710         return ret_arr;
32711 }
32712
32713 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
32714         LDKCommitmentUpdate this_ptr_conv;
32715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32716         this_ptr_conv.is_owned = false;
32717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32718         LDKCVec_UpdateFulfillHTLCZ val_constr;
32719         val_constr.datalen = val->arr_len;
32720         if (val_constr.datalen > 0)
32721                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32722         else
32723                 val_constr.data = NULL;
32724         uint32_t* val_vals = val->elems;
32725         for (size_t t = 0; t < val_constr.datalen; t++) {
32726                 uint32_t val_conv_19 = val_vals[t];
32727                 LDKUpdateFulfillHTLC val_conv_19_conv;
32728                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
32729                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
32730                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
32731                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
32732                 val_constr.data[t] = val_conv_19_conv;
32733         }
32734         FREE(val);
32735         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
32736 }
32737
32738 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
32739         LDKCommitmentUpdate this_ptr_conv;
32740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32741         this_ptr_conv.is_owned = false;
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32743         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
32744         uint32_tArray ret_arr = NULL;
32745         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32746         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32747         for (size_t q = 0; q < ret_var.datalen; q++) {
32748                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
32749                 uint32_t ret_conv_16_ref = 0;
32750                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32751                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32752                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32753                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
32754                 if (ret_conv_16_var.is_owned) {
32755                         ret_conv_16_ref |= 1;
32756                 }
32757                 ret_arr_ptr[q] = ret_conv_16_ref;
32758         }
32759         
32760         FREE(ret_var.data);
32761         return ret_arr;
32762 }
32763
32764 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
32765         LDKCommitmentUpdate this_ptr_conv;
32766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32767         this_ptr_conv.is_owned = false;
32768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32769         LDKCVec_UpdateFailHTLCZ val_constr;
32770         val_constr.datalen = val->arr_len;
32771         if (val_constr.datalen > 0)
32772                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32773         else
32774                 val_constr.data = NULL;
32775         uint32_t* val_vals = val->elems;
32776         for (size_t q = 0; q < val_constr.datalen; q++) {
32777                 uint32_t val_conv_16 = val_vals[q];
32778                 LDKUpdateFailHTLC val_conv_16_conv;
32779                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
32780                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
32781                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32782                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
32783                 val_constr.data[q] = val_conv_16_conv;
32784         }
32785         FREE(val);
32786         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
32787 }
32788
32789 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
32790         LDKCommitmentUpdate this_ptr_conv;
32791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32792         this_ptr_conv.is_owned = false;
32793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32794         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
32795         uint32_tArray ret_arr = NULL;
32796         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32797         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32798         for (size_t z = 0; z < ret_var.datalen; z++) {
32799                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
32800                 uint32_t ret_conv_25_ref = 0;
32801                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32802                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32803                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
32804                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
32805                 if (ret_conv_25_var.is_owned) {
32806                         ret_conv_25_ref |= 1;
32807                 }
32808                 ret_arr_ptr[z] = ret_conv_25_ref;
32809         }
32810         
32811         FREE(ret_var.data);
32812         return ret_arr;
32813 }
32814
32815 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) {
32816         LDKCommitmentUpdate 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         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
32821         val_constr.datalen = val->arr_len;
32822         if (val_constr.datalen > 0)
32823                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32824         else
32825                 val_constr.data = NULL;
32826         uint32_t* val_vals = val->elems;
32827         for (size_t z = 0; z < val_constr.datalen; z++) {
32828                 uint32_t val_conv_25 = val_vals[z];
32829                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
32830                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
32831                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
32832                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
32833                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
32834                 val_constr.data[z] = val_conv_25_conv;
32835         }
32836         FREE(val);
32837         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
32838 }
32839
32840 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
32841         LDKCommitmentUpdate this_ptr_conv;
32842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32843         this_ptr_conv.is_owned = false;
32844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32845         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
32846         uint32_t ret_ref = 0;
32847         if ((uintptr_t)ret_var.inner > 4096) {
32848                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32849                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32851                 ret_ref = (uintptr_t)ret_var.inner;
32852                 if (ret_var.is_owned) {
32853                         ret_ref |= 1;
32854                 }
32855         }
32856         return ret_ref;
32857 }
32858
32859 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
32860         LDKCommitmentUpdate this_ptr_conv;
32861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32862         this_ptr_conv.is_owned = false;
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32864         LDKUpdateFee val_conv;
32865         val_conv.inner = (void*)(val & (~1));
32866         val_conv.is_owned = (val & 1) || (val == 0);
32867         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32868         val_conv = UpdateFee_clone(&val_conv);
32869         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
32870 }
32871
32872 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
32873         LDKCommitmentUpdate this_ptr_conv;
32874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32875         this_ptr_conv.is_owned = false;
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32877         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
32878         uint32_t ret_ref = 0;
32879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32882         ret_ref = (uintptr_t)ret_var.inner;
32883         if (ret_var.is_owned) {
32884                 ret_ref |= 1;
32885         }
32886         return ret_ref;
32887 }
32888
32889 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
32890         LDKCommitmentUpdate this_ptr_conv;
32891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32892         this_ptr_conv.is_owned = false;
32893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32894         LDKCommitmentSigned val_conv;
32895         val_conv.inner = (void*)(val & (~1));
32896         val_conv.is_owned = (val & 1) || (val == 0);
32897         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32898         val_conv = CommitmentSigned_clone(&val_conv);
32899         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
32900 }
32901
32902 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) {
32903         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
32904         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
32905         if (update_add_htlcs_arg_constr.datalen > 0)
32906                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32907         else
32908                 update_add_htlcs_arg_constr.data = NULL;
32909         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
32910         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
32911                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
32912                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
32913                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
32914                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
32915                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
32916                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
32917                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
32918         }
32919         FREE(update_add_htlcs_arg);
32920         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
32921         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
32922         if (update_fulfill_htlcs_arg_constr.datalen > 0)
32923                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32924         else
32925                 update_fulfill_htlcs_arg_constr.data = NULL;
32926         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
32927         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
32928                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
32929                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
32930                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
32931                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
32932                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
32933                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
32934                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
32935         }
32936         FREE(update_fulfill_htlcs_arg);
32937         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
32938         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
32939         if (update_fail_htlcs_arg_constr.datalen > 0)
32940                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32941         else
32942                 update_fail_htlcs_arg_constr.data = NULL;
32943         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
32944         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
32945                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
32946                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
32947                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
32948                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
32949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
32950                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
32951                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
32952         }
32953         FREE(update_fail_htlcs_arg);
32954         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
32955         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
32956         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
32957                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32958         else
32959                 update_fail_malformed_htlcs_arg_constr.data = NULL;
32960         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
32961         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
32962                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
32963                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
32964                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
32965                 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);
32966                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
32967                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
32968                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
32969         }
32970         FREE(update_fail_malformed_htlcs_arg);
32971         LDKUpdateFee update_fee_arg_conv;
32972         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
32973         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
32974         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
32975         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
32976         LDKCommitmentSigned commitment_signed_arg_conv;
32977         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
32978         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
32979         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
32980         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
32981         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);
32982         uint32_t ret_ref = 0;
32983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32986         ret_ref = (uintptr_t)ret_var.inner;
32987         if (ret_var.is_owned) {
32988                 ret_ref |= 1;
32989         }
32990         return ret_ref;
32991 }
32992
32993 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
32994         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
32995 uint32_t ret_ref = 0;
32996 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32997 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32999 ret_ref = (uintptr_t)ret_var.inner;
33000 if (ret_var.is_owned) {
33001         ret_ref |= 1;
33002 }
33003         return ret_ref;
33004 }
33005 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
33006         LDKCommitmentUpdate arg_conv;
33007         arg_conv.inner = (void*)(arg & (~1));
33008         arg_conv.is_owned = false;
33009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33010         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33011         return ret_conv;
33012 }
33013
33014 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
33015         LDKCommitmentUpdate orig_conv;
33016         orig_conv.inner = (void*)(orig & (~1));
33017         orig_conv.is_owned = false;
33018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33019         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33020         uint32_t ret_ref = 0;
33021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33024         ret_ref = (uintptr_t)ret_var.inner;
33025         if (ret_var.is_owned) {
33026                 ret_ref |= 1;
33027         }
33028         return ret_ref;
33029 }
33030
33031 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
33032         if ((this_ptr & 1) != 0) return;
33033         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33034         CHECK_ACCESS(this_ptr_ptr);
33035         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33036         FREE((void*)this_ptr);
33037         ChannelMessageHandler_free(this_ptr_conv);
33038 }
33039
33040 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
33041         if ((this_ptr & 1) != 0) return;
33042         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33043         CHECK_ACCESS(this_ptr_ptr);
33044         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33045         FREE((void*)this_ptr);
33046         RoutingMessageHandler_free(this_ptr_conv);
33047 }
33048
33049 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
33050         LDKAcceptChannel obj_conv;
33051         obj_conv.inner = (void*)(obj & (~1));
33052         obj_conv.is_owned = false;
33053         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33054         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33055         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33056         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33057         CVec_u8Z_free(ret_var);
33058         return ret_arr;
33059 }
33060
33061 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33062         LDKu8slice ser_ref;
33063         ser_ref.datalen = ser->arr_len;
33064         ser_ref.data = ser->elems;
33065         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33066         *ret_conv = AcceptChannel_read(ser_ref);
33067         FREE(ser);
33068         return (uint32_t)ret_conv;
33069 }
33070
33071 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
33072         LDKAnnouncementSignatures obj_conv;
33073         obj_conv.inner = (void*)(obj & (~1));
33074         obj_conv.is_owned = false;
33075         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33076         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33077         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33078         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33079         CVec_u8Z_free(ret_var);
33080         return ret_arr;
33081 }
33082
33083 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33084         LDKu8slice ser_ref;
33085         ser_ref.datalen = ser->arr_len;
33086         ser_ref.data = ser->elems;
33087         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33088         *ret_conv = AnnouncementSignatures_read(ser_ref);
33089         FREE(ser);
33090         return (uint32_t)ret_conv;
33091 }
33092
33093 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
33094         LDKChannelReestablish obj_conv;
33095         obj_conv.inner = (void*)(obj & (~1));
33096         obj_conv.is_owned = false;
33097         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33098         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33101         CVec_u8Z_free(ret_var);
33102         return ret_arr;
33103 }
33104
33105 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33106         LDKu8slice ser_ref;
33107         ser_ref.datalen = ser->arr_len;
33108         ser_ref.data = ser->elems;
33109         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33110         *ret_conv = ChannelReestablish_read(ser_ref);
33111         FREE(ser);
33112         return (uint32_t)ret_conv;
33113 }
33114
33115 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
33116         LDKClosingSigned obj_conv;
33117         obj_conv.inner = (void*)(obj & (~1));
33118         obj_conv.is_owned = false;
33119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33120         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33121         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33122         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33123         CVec_u8Z_free(ret_var);
33124         return ret_arr;
33125 }
33126
33127 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33128         LDKu8slice ser_ref;
33129         ser_ref.datalen = ser->arr_len;
33130         ser_ref.data = ser->elems;
33131         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33132         *ret_conv = ClosingSigned_read(ser_ref);
33133         FREE(ser);
33134         return (uint32_t)ret_conv;
33135 }
33136
33137 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
33138         LDKClosingSignedFeeRange obj_conv;
33139         obj_conv.inner = (void*)(obj & (~1));
33140         obj_conv.is_owned = false;
33141         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33142         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33143         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33144         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33145         CVec_u8Z_free(ret_var);
33146         return ret_arr;
33147 }
33148
33149 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33150         LDKu8slice ser_ref;
33151         ser_ref.datalen = ser->arr_len;
33152         ser_ref.data = ser->elems;
33153         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33154         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33155         FREE(ser);
33156         return (uint32_t)ret_conv;
33157 }
33158
33159 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
33160         LDKCommitmentSigned obj_conv;
33161         obj_conv.inner = (void*)(obj & (~1));
33162         obj_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33164         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33165         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33166         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33167         CVec_u8Z_free(ret_var);
33168         return ret_arr;
33169 }
33170
33171 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33172         LDKu8slice ser_ref;
33173         ser_ref.datalen = ser->arr_len;
33174         ser_ref.data = ser->elems;
33175         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33176         *ret_conv = CommitmentSigned_read(ser_ref);
33177         FREE(ser);
33178         return (uint32_t)ret_conv;
33179 }
33180
33181 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
33182         LDKFundingCreated obj_conv;
33183         obj_conv.inner = (void*)(obj & (~1));
33184         obj_conv.is_owned = false;
33185         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33186         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33187         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33188         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33189         CVec_u8Z_free(ret_var);
33190         return ret_arr;
33191 }
33192
33193 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33194         LDKu8slice ser_ref;
33195         ser_ref.datalen = ser->arr_len;
33196         ser_ref.data = ser->elems;
33197         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
33198         *ret_conv = FundingCreated_read(ser_ref);
33199         FREE(ser);
33200         return (uint32_t)ret_conv;
33201 }
33202
33203 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
33204         LDKFundingSigned obj_conv;
33205         obj_conv.inner = (void*)(obj & (~1));
33206         obj_conv.is_owned = false;
33207         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33208         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
33209         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33210         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33211         CVec_u8Z_free(ret_var);
33212         return ret_arr;
33213 }
33214
33215 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
33216         LDKu8slice ser_ref;
33217         ser_ref.datalen = ser->arr_len;
33218         ser_ref.data = ser->elems;
33219         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
33220         *ret_conv = FundingSigned_read(ser_ref);
33221         FREE(ser);
33222         return (uint32_t)ret_conv;
33223 }
33224
33225 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
33226         LDKChannelReady obj_conv;
33227         obj_conv.inner = (void*)(obj & (~1));
33228         obj_conv.is_owned = false;
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33230         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
33231         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33232         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33233         CVec_u8Z_free(ret_var);
33234         return ret_arr;
33235 }
33236
33237 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
33238         LDKu8slice ser_ref;
33239         ser_ref.datalen = ser->arr_len;
33240         ser_ref.data = ser->elems;
33241         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
33242         *ret_conv = ChannelReady_read(ser_ref);
33243         FREE(ser);
33244         return (uint32_t)ret_conv;
33245 }
33246
33247 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
33248         LDKInit obj_conv;
33249         obj_conv.inner = (void*)(obj & (~1));
33250         obj_conv.is_owned = false;
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33252         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
33253         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33254         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33255         CVec_u8Z_free(ret_var);
33256         return ret_arr;
33257 }
33258
33259 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
33260         LDKu8slice ser_ref;
33261         ser_ref.datalen = ser->arr_len;
33262         ser_ref.data = ser->elems;
33263         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
33264         *ret_conv = Init_read(ser_ref);
33265         FREE(ser);
33266         return (uint32_t)ret_conv;
33267 }
33268
33269 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
33270         LDKOpenChannel obj_conv;
33271         obj_conv.inner = (void*)(obj & (~1));
33272         obj_conv.is_owned = false;
33273         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33274         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
33275         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33276         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33277         CVec_u8Z_free(ret_var);
33278         return ret_arr;
33279 }
33280
33281 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
33282         LDKu8slice ser_ref;
33283         ser_ref.datalen = ser->arr_len;
33284         ser_ref.data = ser->elems;
33285         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
33286         *ret_conv = OpenChannel_read(ser_ref);
33287         FREE(ser);
33288         return (uint32_t)ret_conv;
33289 }
33290
33291 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
33292         LDKRevokeAndACK obj_conv;
33293         obj_conv.inner = (void*)(obj & (~1));
33294         obj_conv.is_owned = false;
33295         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33296         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
33297         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33298         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33299         CVec_u8Z_free(ret_var);
33300         return ret_arr;
33301 }
33302
33303 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
33304         LDKu8slice ser_ref;
33305         ser_ref.datalen = ser->arr_len;
33306         ser_ref.data = ser->elems;
33307         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
33308         *ret_conv = RevokeAndACK_read(ser_ref);
33309         FREE(ser);
33310         return (uint32_t)ret_conv;
33311 }
33312
33313 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
33314         LDKShutdown obj_conv;
33315         obj_conv.inner = (void*)(obj & (~1));
33316         obj_conv.is_owned = false;
33317         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33318         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
33319         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33320         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33321         CVec_u8Z_free(ret_var);
33322         return ret_arr;
33323 }
33324
33325 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
33326         LDKu8slice ser_ref;
33327         ser_ref.datalen = ser->arr_len;
33328         ser_ref.data = ser->elems;
33329         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
33330         *ret_conv = Shutdown_read(ser_ref);
33331         FREE(ser);
33332         return (uint32_t)ret_conv;
33333 }
33334
33335 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
33336         LDKUpdateFailHTLC obj_conv;
33337         obj_conv.inner = (void*)(obj & (~1));
33338         obj_conv.is_owned = false;
33339         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33340         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
33341         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33342         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33343         CVec_u8Z_free(ret_var);
33344         return ret_arr;
33345 }
33346
33347 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
33348         LDKu8slice ser_ref;
33349         ser_ref.datalen = ser->arr_len;
33350         ser_ref.data = ser->elems;
33351         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
33352         *ret_conv = UpdateFailHTLC_read(ser_ref);
33353         FREE(ser);
33354         return (uint32_t)ret_conv;
33355 }
33356
33357 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
33358         LDKUpdateFailMalformedHTLC obj_conv;
33359         obj_conv.inner = (void*)(obj & (~1));
33360         obj_conv.is_owned = false;
33361         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33362         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
33363         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33364         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33365         CVec_u8Z_free(ret_var);
33366         return ret_arr;
33367 }
33368
33369 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
33370         LDKu8slice ser_ref;
33371         ser_ref.datalen = ser->arr_len;
33372         ser_ref.data = ser->elems;
33373         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
33374         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
33375         FREE(ser);
33376         return (uint32_t)ret_conv;
33377 }
33378
33379 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
33380         LDKUpdateFee obj_conv;
33381         obj_conv.inner = (void*)(obj & (~1));
33382         obj_conv.is_owned = false;
33383         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33384         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
33385         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33386         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33387         CVec_u8Z_free(ret_var);
33388         return ret_arr;
33389 }
33390
33391 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
33392         LDKu8slice ser_ref;
33393         ser_ref.datalen = ser->arr_len;
33394         ser_ref.data = ser->elems;
33395         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
33396         *ret_conv = UpdateFee_read(ser_ref);
33397         FREE(ser);
33398         return (uint32_t)ret_conv;
33399 }
33400
33401 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
33402         LDKUpdateFulfillHTLC obj_conv;
33403         obj_conv.inner = (void*)(obj & (~1));
33404         obj_conv.is_owned = false;
33405         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33406         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
33407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33409         CVec_u8Z_free(ret_var);
33410         return ret_arr;
33411 }
33412
33413 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
33414         LDKu8slice ser_ref;
33415         ser_ref.datalen = ser->arr_len;
33416         ser_ref.data = ser->elems;
33417         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
33418         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
33419         FREE(ser);
33420         return (uint32_t)ret_conv;
33421 }
33422
33423 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
33424         LDKUpdateAddHTLC obj_conv;
33425         obj_conv.inner = (void*)(obj & (~1));
33426         obj_conv.is_owned = false;
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33428         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
33429         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33430         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33431         CVec_u8Z_free(ret_var);
33432         return ret_arr;
33433 }
33434
33435 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
33436         LDKu8slice ser_ref;
33437         ser_ref.datalen = ser->arr_len;
33438         ser_ref.data = ser->elems;
33439         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
33440         *ret_conv = UpdateAddHTLC_read(ser_ref);
33441         FREE(ser);
33442         return (uint32_t)ret_conv;
33443 }
33444
33445 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
33446         LDKPing obj_conv;
33447         obj_conv.inner = (void*)(obj & (~1));
33448         obj_conv.is_owned = false;
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33450         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
33451         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33452         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33453         CVec_u8Z_free(ret_var);
33454         return ret_arr;
33455 }
33456
33457 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
33458         LDKu8slice ser_ref;
33459         ser_ref.datalen = ser->arr_len;
33460         ser_ref.data = ser->elems;
33461         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
33462         *ret_conv = Ping_read(ser_ref);
33463         FREE(ser);
33464         return (uint32_t)ret_conv;
33465 }
33466
33467 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
33468         LDKPong obj_conv;
33469         obj_conv.inner = (void*)(obj & (~1));
33470         obj_conv.is_owned = false;
33471         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33472         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
33473         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33474         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33475         CVec_u8Z_free(ret_var);
33476         return ret_arr;
33477 }
33478
33479 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
33480         LDKu8slice ser_ref;
33481         ser_ref.datalen = ser->arr_len;
33482         ser_ref.data = ser->elems;
33483         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
33484         *ret_conv = Pong_read(ser_ref);
33485         FREE(ser);
33486         return (uint32_t)ret_conv;
33487 }
33488
33489 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
33490         LDKUnsignedChannelAnnouncement obj_conv;
33491         obj_conv.inner = (void*)(obj & (~1));
33492         obj_conv.is_owned = false;
33493         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33494         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
33495         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33496         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33497         CVec_u8Z_free(ret_var);
33498         return ret_arr;
33499 }
33500
33501 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
33502         LDKu8slice ser_ref;
33503         ser_ref.datalen = ser->arr_len;
33504         ser_ref.data = ser->elems;
33505         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
33506         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
33507         FREE(ser);
33508         return (uint32_t)ret_conv;
33509 }
33510
33511 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
33512         LDKChannelAnnouncement obj_conv;
33513         obj_conv.inner = (void*)(obj & (~1));
33514         obj_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33516         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
33517         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33518         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33519         CVec_u8Z_free(ret_var);
33520         return ret_arr;
33521 }
33522
33523 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
33524         LDKu8slice ser_ref;
33525         ser_ref.datalen = ser->arr_len;
33526         ser_ref.data = ser->elems;
33527         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
33528         *ret_conv = ChannelAnnouncement_read(ser_ref);
33529         FREE(ser);
33530         return (uint32_t)ret_conv;
33531 }
33532
33533 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
33534         LDKUnsignedChannelUpdate obj_conv;
33535         obj_conv.inner = (void*)(obj & (~1));
33536         obj_conv.is_owned = false;
33537         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33538         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
33539         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33540         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33541         CVec_u8Z_free(ret_var);
33542         return ret_arr;
33543 }
33544
33545 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
33546         LDKu8slice ser_ref;
33547         ser_ref.datalen = ser->arr_len;
33548         ser_ref.data = ser->elems;
33549         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
33550         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
33551         FREE(ser);
33552         return (uint32_t)ret_conv;
33553 }
33554
33555 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
33556         LDKChannelUpdate obj_conv;
33557         obj_conv.inner = (void*)(obj & (~1));
33558         obj_conv.is_owned = false;
33559         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33560         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
33561         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33562         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33563         CVec_u8Z_free(ret_var);
33564         return ret_arr;
33565 }
33566
33567 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
33568         LDKu8slice ser_ref;
33569         ser_ref.datalen = ser->arr_len;
33570         ser_ref.data = ser->elems;
33571         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
33572         *ret_conv = ChannelUpdate_read(ser_ref);
33573         FREE(ser);
33574         return (uint32_t)ret_conv;
33575 }
33576
33577 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
33578         LDKErrorMessage obj_conv;
33579         obj_conv.inner = (void*)(obj & (~1));
33580         obj_conv.is_owned = false;
33581         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33582         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
33583         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33584         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33585         CVec_u8Z_free(ret_var);
33586         return ret_arr;
33587 }
33588
33589 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
33590         LDKu8slice ser_ref;
33591         ser_ref.datalen = ser->arr_len;
33592         ser_ref.data = ser->elems;
33593         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
33594         *ret_conv = ErrorMessage_read(ser_ref);
33595         FREE(ser);
33596         return (uint32_t)ret_conv;
33597 }
33598
33599 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
33600         LDKWarningMessage obj_conv;
33601         obj_conv.inner = (void*)(obj & (~1));
33602         obj_conv.is_owned = false;
33603         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33604         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
33605         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33606         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33607         CVec_u8Z_free(ret_var);
33608         return ret_arr;
33609 }
33610
33611 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
33612         LDKu8slice ser_ref;
33613         ser_ref.datalen = ser->arr_len;
33614         ser_ref.data = ser->elems;
33615         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
33616         *ret_conv = WarningMessage_read(ser_ref);
33617         FREE(ser);
33618         return (uint32_t)ret_conv;
33619 }
33620
33621 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
33622         LDKUnsignedNodeAnnouncement obj_conv;
33623         obj_conv.inner = (void*)(obj & (~1));
33624         obj_conv.is_owned = false;
33625         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33626         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
33627         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33628         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33629         CVec_u8Z_free(ret_var);
33630         return ret_arr;
33631 }
33632
33633 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
33634         LDKu8slice ser_ref;
33635         ser_ref.datalen = ser->arr_len;
33636         ser_ref.data = ser->elems;
33637         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
33638         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
33639         FREE(ser);
33640         return (uint32_t)ret_conv;
33641 }
33642
33643 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
33644         LDKNodeAnnouncement obj_conv;
33645         obj_conv.inner = (void*)(obj & (~1));
33646         obj_conv.is_owned = false;
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33648         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
33649         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33650         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33651         CVec_u8Z_free(ret_var);
33652         return ret_arr;
33653 }
33654
33655 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
33656         LDKu8slice ser_ref;
33657         ser_ref.datalen = ser->arr_len;
33658         ser_ref.data = ser->elems;
33659         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
33660         *ret_conv = NodeAnnouncement_read(ser_ref);
33661         FREE(ser);
33662         return (uint32_t)ret_conv;
33663 }
33664
33665 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
33666         LDKu8slice ser_ref;
33667         ser_ref.datalen = ser->arr_len;
33668         ser_ref.data = ser->elems;
33669         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
33670         *ret_conv = QueryShortChannelIds_read(ser_ref);
33671         FREE(ser);
33672         return (uint32_t)ret_conv;
33673 }
33674
33675 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
33676         LDKQueryShortChannelIds obj_conv;
33677         obj_conv.inner = (void*)(obj & (~1));
33678         obj_conv.is_owned = false;
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33680         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
33681         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33682         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33683         CVec_u8Z_free(ret_var);
33684         return ret_arr;
33685 }
33686
33687 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
33688         LDKReplyShortChannelIdsEnd obj_conv;
33689         obj_conv.inner = (void*)(obj & (~1));
33690         obj_conv.is_owned = false;
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33692         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
33693         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33694         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33695         CVec_u8Z_free(ret_var);
33696         return ret_arr;
33697 }
33698
33699 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
33700         LDKu8slice ser_ref;
33701         ser_ref.datalen = ser->arr_len;
33702         ser_ref.data = ser->elems;
33703         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
33704         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
33705         FREE(ser);
33706         return (uint32_t)ret_conv;
33707 }
33708
33709 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
33710         LDKQueryChannelRange this_arg_conv;
33711         this_arg_conv.inner = (void*)(this_arg & (~1));
33712         this_arg_conv.is_owned = false;
33713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33714         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
33715         return ret_conv;
33716 }
33717
33718 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
33719         LDKQueryChannelRange obj_conv;
33720         obj_conv.inner = (void*)(obj & (~1));
33721         obj_conv.is_owned = false;
33722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33723         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
33724         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33725         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33726         CVec_u8Z_free(ret_var);
33727         return ret_arr;
33728 }
33729
33730 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
33731         LDKu8slice ser_ref;
33732         ser_ref.datalen = ser->arr_len;
33733         ser_ref.data = ser->elems;
33734         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
33735         *ret_conv = QueryChannelRange_read(ser_ref);
33736         FREE(ser);
33737         return (uint32_t)ret_conv;
33738 }
33739
33740 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
33741         LDKu8slice ser_ref;
33742         ser_ref.datalen = ser->arr_len;
33743         ser_ref.data = ser->elems;
33744         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
33745         *ret_conv = ReplyChannelRange_read(ser_ref);
33746         FREE(ser);
33747         return (uint32_t)ret_conv;
33748 }
33749
33750 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
33751         LDKReplyChannelRange obj_conv;
33752         obj_conv.inner = (void*)(obj & (~1));
33753         obj_conv.is_owned = false;
33754         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33755         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
33756         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33757         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33758         CVec_u8Z_free(ret_var);
33759         return ret_arr;
33760 }
33761
33762 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
33763         LDKGossipTimestampFilter obj_conv;
33764         obj_conv.inner = (void*)(obj & (~1));
33765         obj_conv.is_owned = false;
33766         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33767         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
33768         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33769         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33770         CVec_u8Z_free(ret_var);
33771         return ret_arr;
33772 }
33773
33774 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
33775         LDKu8slice ser_ref;
33776         ser_ref.datalen = ser->arr_len;
33777         ser_ref.data = ser->elems;
33778         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
33779         *ret_conv = GossipTimestampFilter_read(ser_ref);
33780         FREE(ser);
33781         return (uint32_t)ret_conv;
33782 }
33783
33784 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
33785         if ((this_ptr & 1) != 0) return;
33786         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33787         CHECK_ACCESS(this_ptr_ptr);
33788         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
33789         FREE((void*)this_ptr);
33790         CustomMessageHandler_free(this_ptr_conv);
33791 }
33792
33793 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
33794         LDKIgnoringMessageHandler this_obj_conv;
33795         this_obj_conv.inner = (void*)(this_obj & (~1));
33796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33798         IgnoringMessageHandler_free(this_obj_conv);
33799 }
33800
33801 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
33802         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
33803         uint32_t ret_ref = 0;
33804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33807         ret_ref = (uintptr_t)ret_var.inner;
33808         if (ret_var.is_owned) {
33809                 ret_ref |= 1;
33810         }
33811         return ret_ref;
33812 }
33813
33814 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33815         LDKIgnoringMessageHandler this_arg_conv;
33816         this_arg_conv.inner = (void*)(this_arg & (~1));
33817         this_arg_conv.is_owned = false;
33818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33819         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33820         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33821         return (uint32_t)ret_ret;
33822 }
33823
33824 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
33825         LDKIgnoringMessageHandler this_arg_conv;
33826         this_arg_conv.inner = (void*)(this_arg & (~1));
33827         this_arg_conv.is_owned = false;
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33829         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
33830         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
33831         return (uint32_t)ret_ret;
33832 }
33833
33834 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
33835         LDKIgnoringMessageHandler this_arg_conv;
33836         this_arg_conv.inner = (void*)(this_arg & (~1));
33837         this_arg_conv.is_owned = false;
33838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33839         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
33840         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
33841         return (uint32_t)ret_ret;
33842 }
33843
33844 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
33845         LDKIgnoringMessageHandler this_arg_conv;
33846         this_arg_conv.inner = (void*)(this_arg & (~1));
33847         this_arg_conv.is_owned = false;
33848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33849         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
33850         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
33851         return (uint32_t)ret_ret;
33852 }
33853
33854 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
33855         LDKErroringMessageHandler this_obj_conv;
33856         this_obj_conv.inner = (void*)(this_obj & (~1));
33857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33859         ErroringMessageHandler_free(this_obj_conv);
33860 }
33861
33862 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
33863         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
33864         uint32_t ret_ref = 0;
33865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33868         ret_ref = (uintptr_t)ret_var.inner;
33869         if (ret_var.is_owned) {
33870                 ret_ref |= 1;
33871         }
33872         return ret_ref;
33873 }
33874
33875 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33876         LDKErroringMessageHandler this_arg_conv;
33877         this_arg_conv.inner = (void*)(this_arg & (~1));
33878         this_arg_conv.is_owned = false;
33879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33880         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33881         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33882         return (uint32_t)ret_ret;
33883 }
33884
33885 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
33886         LDKErroringMessageHandler this_arg_conv;
33887         this_arg_conv.inner = (void*)(this_arg & (~1));
33888         this_arg_conv.is_owned = false;
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33890         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33891         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
33892         return (uint32_t)ret_ret;
33893 }
33894
33895 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
33896         LDKMessageHandler this_obj_conv;
33897         this_obj_conv.inner = (void*)(this_obj & (~1));
33898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33900         MessageHandler_free(this_obj_conv);
33901 }
33902
33903 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
33904         LDKMessageHandler this_ptr_conv;
33905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33906         this_ptr_conv.is_owned = false;
33907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33908         // WARNING: This object doesn't live past this scope, needs clone!
33909         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
33910         return ret_ret;
33911 }
33912
33913 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
33914         LDKMessageHandler this_ptr_conv;
33915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33916         this_ptr_conv.is_owned = false;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33918         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33919         CHECK_ACCESS(val_ptr);
33920         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
33921         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
33922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33923                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
33924         }
33925         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
33926 }
33927
33928 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
33929         LDKMessageHandler this_ptr_conv;
33930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33931         this_ptr_conv.is_owned = false;
33932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33933         // WARNING: This object doesn't live past this scope, needs clone!
33934         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
33935         return ret_ret;
33936 }
33937
33938 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
33939         LDKMessageHandler this_ptr_conv;
33940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33941         this_ptr_conv.is_owned = false;
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33943         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33944         CHECK_ACCESS(val_ptr);
33945         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
33946         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33947                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33948                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
33949         }
33950         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
33951 }
33952
33953 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
33954         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
33955         CHECK_ACCESS(chan_handler_arg_ptr);
33956         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
33957         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
33958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33959                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
33960         }
33961         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
33962         CHECK_ACCESS(route_handler_arg_ptr);
33963         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
33964         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33966                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
33967         }
33968         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
33969         uint32_t ret_ref = 0;
33970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33973         ret_ref = (uintptr_t)ret_var.inner;
33974         if (ret_var.is_owned) {
33975                 ret_ref |= 1;
33976         }
33977         return ret_ref;
33978 }
33979
33980 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
33981         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33982         *ret_ret = SocketDescriptor_clone(arg);
33983         return (uint32_t)ret_ret;
33984 }
33985 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
33986         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
33987         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
33988         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
33989         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
33990         return ret_conv;
33991 }
33992
33993 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
33994         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
33995         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
33996         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
33997         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33998         *ret_ret = SocketDescriptor_clone(orig_conv);
33999         return (uint32_t)ret_ret;
34000 }
34001
34002 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
34003         if ((this_ptr & 1) != 0) return;
34004         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34005         CHECK_ACCESS(this_ptr_ptr);
34006         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34007         FREE((void*)this_ptr);
34008         SocketDescriptor_free(this_ptr_conv);
34009 }
34010
34011 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
34012         LDKPeerHandleError this_obj_conv;
34013         this_obj_conv.inner = (void*)(this_obj & (~1));
34014         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34016         PeerHandleError_free(this_obj_conv);
34017 }
34018
34019 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
34020         LDKPeerHandleError this_ptr_conv;
34021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34022         this_ptr_conv.is_owned = false;
34023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34024         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34025         return ret_conv;
34026 }
34027
34028 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
34029         LDKPeerHandleError this_ptr_conv;
34030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34031         this_ptr_conv.is_owned = false;
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34033         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34034 }
34035
34036 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34037         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34038         uint32_t ret_ref = 0;
34039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34042         ret_ref = (uintptr_t)ret_var.inner;
34043         if (ret_var.is_owned) {
34044                 ret_ref |= 1;
34045         }
34046         return ret_ref;
34047 }
34048
34049 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34050         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34051 uint32_t ret_ref = 0;
34052 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34053 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34054 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34055 ret_ref = (uintptr_t)ret_var.inner;
34056 if (ret_var.is_owned) {
34057         ret_ref |= 1;
34058 }
34059         return ret_ref;
34060 }
34061 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
34062         LDKPeerHandleError arg_conv;
34063         arg_conv.inner = (void*)(arg & (~1));
34064         arg_conv.is_owned = false;
34065         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34066         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34067         return ret_conv;
34068 }
34069
34070 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
34071         LDKPeerHandleError orig_conv;
34072         orig_conv.inner = (void*)(orig & (~1));
34073         orig_conv.is_owned = false;
34074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34075         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34076         uint32_t ret_ref = 0;
34077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34080         ret_ref = (uintptr_t)ret_var.inner;
34081         if (ret_var.is_owned) {
34082                 ret_ref |= 1;
34083         }
34084         return ret_ref;
34085 }
34086
34087 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
34088         LDKPeerManager this_obj_conv;
34089         this_obj_conv.inner = (void*)(this_obj & (~1));
34090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34092         PeerManager_free(this_obj_conv);
34093 }
34094
34095 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) {
34096         LDKMessageHandler message_handler_conv;
34097         message_handler_conv.inner = (void*)(message_handler & (~1));
34098         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
34099         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34100         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34101         LDKSecretKey our_node_secret_ref;
34102         CHECK(our_node_secret->arr_len == 32);
34103         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34104         unsigned char ephemeral_random_data_arr[32];
34105         CHECK(ephemeral_random_data->arr_len == 32);
34106         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34107         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34108         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34109         CHECK_ACCESS(logger_ptr);
34110         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34111         if (logger_conv.free == LDKLogger_JCalls_free) {
34112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34113                 LDKLogger_JCalls_cloned(&logger_conv);
34114         }
34115         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
34116         CHECK_ACCESS(custom_message_handler_ptr);
34117         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34118         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34120                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34121         }
34122         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34123         uint32_t ret_ref = 0;
34124         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34125         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34127         ret_ref = (uintptr_t)ret_var.inner;
34128         if (ret_var.is_owned) {
34129                 ret_ref |= 1;
34130         }
34131         return ret_ref;
34132 }
34133
34134 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
34135         LDKPeerManager this_arg_conv;
34136         this_arg_conv.inner = (void*)(this_arg & (~1));
34137         this_arg_conv.is_owned = false;
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34139         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34140         ptrArray ret_arr = NULL;
34141         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34142         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
34143         for (size_t m = 0; m < ret_var.datalen; m++) {
34144                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34145                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34146                 ret_arr_ptr[m] = ret_conv_12_arr;
34147         }
34148         
34149         FREE(ret_var.data);
34150         return ret_arr;
34151 }
34152
34153 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) {
34154         LDKPeerManager this_arg_conv;
34155         this_arg_conv.inner = (void*)(this_arg & (~1));
34156         this_arg_conv.is_owned = false;
34157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34158         LDKPublicKey their_node_id_ref;
34159         CHECK(their_node_id->arr_len == 33);
34160         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34161         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34162         CHECK_ACCESS(descriptor_ptr);
34163         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34164         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34166                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34167         }
34168         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34169         CHECK_ACCESS(remote_network_address_ptr);
34170         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34171         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34172         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34173         return (uint32_t)ret_conv;
34174 }
34175
34176 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) {
34177         LDKPeerManager this_arg_conv;
34178         this_arg_conv.inner = (void*)(this_arg & (~1));
34179         this_arg_conv.is_owned = false;
34180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34181         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34182         CHECK_ACCESS(descriptor_ptr);
34183         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34184         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34185                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34186                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34187         }
34188         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34189         CHECK_ACCESS(remote_network_address_ptr);
34190         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34191         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34192         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34193         return (uint32_t)ret_conv;
34194 }
34195
34196 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
34197         LDKPeerManager this_arg_conv;
34198         this_arg_conv.inner = (void*)(this_arg & (~1));
34199         this_arg_conv.is_owned = false;
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34201         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34202         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34203         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34204         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34205         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
34206         return (uint32_t)ret_conv;
34207 }
34208
34209 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
34210         LDKPeerManager this_arg_conv;
34211         this_arg_conv.inner = (void*)(this_arg & (~1));
34212         this_arg_conv.is_owned = false;
34213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34214         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
34215         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
34216         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
34217         LDKu8slice data_ref;
34218         data_ref.datalen = data->arr_len;
34219         data_ref.data = data->elems;
34220         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
34221         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
34222         FREE(data);
34223         return (uint32_t)ret_conv;
34224 }
34225
34226 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
34227         LDKPeerManager this_arg_conv;
34228         this_arg_conv.inner = (void*)(this_arg & (~1));
34229         this_arg_conv.is_owned = false;
34230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34231         PeerManager_process_events(&this_arg_conv);
34232 }
34233
34234 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
34235         LDKPeerManager this_arg_conv;
34236         this_arg_conv.inner = (void*)(this_arg & (~1));
34237         this_arg_conv.is_owned = false;
34238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34239         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34240         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34241         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34242         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
34243 }
34244
34245 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) {
34246         LDKPeerManager this_arg_conv;
34247         this_arg_conv.inner = (void*)(this_arg & (~1));
34248         this_arg_conv.is_owned = false;
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34250         LDKPublicKey node_id_ref;
34251         CHECK(node_id->arr_len == 33);
34252         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
34253         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
34254 }
34255
34256 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
34257         LDKPeerManager this_arg_conv;
34258         this_arg_conv.inner = (void*)(this_arg & (~1));
34259         this_arg_conv.is_owned = false;
34260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34261         PeerManager_disconnect_all_peers(&this_arg_conv);
34262 }
34263
34264 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
34265         LDKPeerManager this_arg_conv;
34266         this_arg_conv.inner = (void*)(this_arg & (~1));
34267         this_arg_conv.is_owned = false;
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34269         PeerManager_timer_tick_occurred(&this_arg_conv);
34270 }
34271
34272 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
34273         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
34274         return ret_conv;
34275 }
34276
34277 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
34278         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
34279         return ret_conv;
34280 }
34281
34282 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
34283         unsigned char commitment_seed_arr[32];
34284         CHECK(commitment_seed->arr_len == 32);
34285         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
34286         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
34287         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34288         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
34289         return ret_arr;
34290 }
34291
34292 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) {
34293         LDKCVec_u8Z to_holder_script_ref;
34294         to_holder_script_ref.datalen = to_holder_script->arr_len;
34295         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34296         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34297         LDKCVec_u8Z to_counterparty_script_ref;
34298         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34299         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34300         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34301         LDKOutPoint funding_outpoint_conv;
34302         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34303         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34304         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34305         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34306         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);
34307         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34308         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34309         Transaction_free(ret_var);
34310         return ret_arr;
34311 }
34312
34313 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
34314         LDKCounterpartyCommitmentSecrets this_obj_conv;
34315         this_obj_conv.inner = (void*)(this_obj & (~1));
34316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34318         CounterpartyCommitmentSecrets_free(this_obj_conv);
34319 }
34320
34321 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
34322         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
34323 uint32_t ret_ref = 0;
34324 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34325 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34326 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34327 ret_ref = (uintptr_t)ret_var.inner;
34328 if (ret_var.is_owned) {
34329         ret_ref |= 1;
34330 }
34331         return ret_ref;
34332 }
34333 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
34334         LDKCounterpartyCommitmentSecrets arg_conv;
34335         arg_conv.inner = (void*)(arg & (~1));
34336         arg_conv.is_owned = false;
34337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34338         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
34339         return ret_conv;
34340 }
34341
34342 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
34343         LDKCounterpartyCommitmentSecrets orig_conv;
34344         orig_conv.inner = (void*)(orig & (~1));
34345         orig_conv.is_owned = false;
34346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34347         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
34348         uint32_t ret_ref = 0;
34349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34352         ret_ref = (uintptr_t)ret_var.inner;
34353         if (ret_var.is_owned) {
34354                 ret_ref |= 1;
34355         }
34356         return ret_ref;
34357 }
34358
34359 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
34360         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
34361         uint32_t ret_ref = 0;
34362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34365         ret_ref = (uintptr_t)ret_var.inner;
34366         if (ret_var.is_owned) {
34367                 ret_ref |= 1;
34368         }
34369         return ret_ref;
34370 }
34371
34372 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
34373         LDKCounterpartyCommitmentSecrets this_arg_conv;
34374         this_arg_conv.inner = (void*)(this_arg & (~1));
34375         this_arg_conv.is_owned = false;
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34377         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
34378         return ret_conv;
34379 }
34380
34381 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
34382         LDKCounterpartyCommitmentSecrets this_arg_conv;
34383         this_arg_conv.inner = (void*)(this_arg & (~1));
34384         this_arg_conv.is_owned = false;
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34386         LDKThirtyTwoBytes secret_ref;
34387         CHECK(secret->arr_len == 32);
34388         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
34389         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
34390         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
34391         return (uint32_t)ret_conv;
34392 }
34393
34394 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
34395         LDKCounterpartyCommitmentSecrets this_arg_conv;
34396         this_arg_conv.inner = (void*)(this_arg & (~1));
34397         this_arg_conv.is_owned = false;
34398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34399         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34400         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
34401         return ret_arr;
34402 }
34403
34404 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
34405         LDKCounterpartyCommitmentSecrets obj_conv;
34406         obj_conv.inner = (void*)(obj & (~1));
34407         obj_conv.is_owned = false;
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34409         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
34410         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34411         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34412         CVec_u8Z_free(ret_var);
34413         return ret_arr;
34414 }
34415
34416 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
34417         LDKu8slice ser_ref;
34418         ser_ref.datalen = ser->arr_len;
34419         ser_ref.data = ser->elems;
34420         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
34421         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
34422         FREE(ser);
34423         return (uint32_t)ret_conv;
34424 }
34425
34426 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
34427         LDKPublicKey per_commitment_point_ref;
34428         CHECK(per_commitment_point->arr_len == 33);
34429         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34430         unsigned char base_secret_arr[32];
34431         CHECK(base_secret->arr_len == 32);
34432         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
34433         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
34434         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34435         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
34436         return (uint32_t)ret_conv;
34437 }
34438
34439 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
34440         LDKPublicKey per_commitment_point_ref;
34441         CHECK(per_commitment_point->arr_len == 33);
34442         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34443         LDKPublicKey base_point_ref;
34444         CHECK(base_point->arr_len == 33);
34445         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
34446         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34447         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
34448         return (uint32_t)ret_conv;
34449 }
34450
34451 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) {
34452         unsigned char per_commitment_secret_arr[32];
34453         CHECK(per_commitment_secret->arr_len == 32);
34454         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
34455         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
34456         unsigned char countersignatory_revocation_base_secret_arr[32];
34457         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
34458         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
34459         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
34460         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34461         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
34462         return (uint32_t)ret_conv;
34463 }
34464
34465 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) {
34466         LDKPublicKey per_commitment_point_ref;
34467         CHECK(per_commitment_point->arr_len == 33);
34468         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34469         LDKPublicKey countersignatory_revocation_base_point_ref;
34470         CHECK(countersignatory_revocation_base_point->arr_len == 33);
34471         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
34472         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34473         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
34474         return (uint32_t)ret_conv;
34475 }
34476
34477 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
34478         LDKTxCreationKeys this_obj_conv;
34479         this_obj_conv.inner = (void*)(this_obj & (~1));
34480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34482         TxCreationKeys_free(this_obj_conv);
34483 }
34484
34485 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
34486         LDKTxCreationKeys this_ptr_conv;
34487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34488         this_ptr_conv.is_owned = false;
34489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34490         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34491         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
34492         return ret_arr;
34493 }
34494
34495 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
34496         LDKTxCreationKeys this_ptr_conv;
34497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34498         this_ptr_conv.is_owned = false;
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34500         LDKPublicKey val_ref;
34501         CHECK(val->arr_len == 33);
34502         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34503         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
34504 }
34505
34506 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
34507         LDKTxCreationKeys this_ptr_conv;
34508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34509         this_ptr_conv.is_owned = false;
34510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34511         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34512         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
34513         return ret_arr;
34514 }
34515
34516 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
34517         LDKTxCreationKeys this_ptr_conv;
34518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34519         this_ptr_conv.is_owned = false;
34520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34521         LDKPublicKey val_ref;
34522         CHECK(val->arr_len == 33);
34523         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34524         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
34525 }
34526
34527 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
34528         LDKTxCreationKeys this_ptr_conv;
34529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34530         this_ptr_conv.is_owned = false;
34531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34532         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34533         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
34534         return ret_arr;
34535 }
34536
34537 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
34538         LDKTxCreationKeys this_ptr_conv;
34539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34540         this_ptr_conv.is_owned = false;
34541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34542         LDKPublicKey val_ref;
34543         CHECK(val->arr_len == 33);
34544         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34545         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
34546 }
34547
34548 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
34549         LDKTxCreationKeys this_ptr_conv;
34550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34551         this_ptr_conv.is_owned = false;
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34553         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34554         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
34555         return ret_arr;
34556 }
34557
34558 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
34559         LDKTxCreationKeys this_ptr_conv;
34560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34561         this_ptr_conv.is_owned = false;
34562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34563         LDKPublicKey val_ref;
34564         CHECK(val->arr_len == 33);
34565         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34566         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
34567 }
34568
34569 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
34570         LDKTxCreationKeys this_ptr_conv;
34571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34572         this_ptr_conv.is_owned = false;
34573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34574         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34575         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
34576         return ret_arr;
34577 }
34578
34579 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) {
34580         LDKTxCreationKeys this_ptr_conv;
34581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34582         this_ptr_conv.is_owned = false;
34583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34584         LDKPublicKey val_ref;
34585         CHECK(val->arr_len == 33);
34586         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34587         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
34588 }
34589
34590 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) {
34591         LDKPublicKey per_commitment_point_arg_ref;
34592         CHECK(per_commitment_point_arg->arr_len == 33);
34593         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
34594         LDKPublicKey revocation_key_arg_ref;
34595         CHECK(revocation_key_arg->arr_len == 33);
34596         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
34597         LDKPublicKey broadcaster_htlc_key_arg_ref;
34598         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
34599         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
34600         LDKPublicKey countersignatory_htlc_key_arg_ref;
34601         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
34602         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
34603         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
34604         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
34605         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
34606         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);
34607         uint32_t ret_ref = 0;
34608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34611         ret_ref = (uintptr_t)ret_var.inner;
34612         if (ret_var.is_owned) {
34613                 ret_ref |= 1;
34614         }
34615         return ret_ref;
34616 }
34617
34618 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
34619         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
34620 uint32_t ret_ref = 0;
34621 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34622 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34623 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34624 ret_ref = (uintptr_t)ret_var.inner;
34625 if (ret_var.is_owned) {
34626         ret_ref |= 1;
34627 }
34628         return ret_ref;
34629 }
34630 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
34631         LDKTxCreationKeys arg_conv;
34632         arg_conv.inner = (void*)(arg & (~1));
34633         arg_conv.is_owned = false;
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34635         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
34636         return ret_conv;
34637 }
34638
34639 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
34640         LDKTxCreationKeys orig_conv;
34641         orig_conv.inner = (void*)(orig & (~1));
34642         orig_conv.is_owned = false;
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34644         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
34645         uint32_t ret_ref = 0;
34646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34649         ret_ref = (uintptr_t)ret_var.inner;
34650         if (ret_var.is_owned) {
34651                 ret_ref |= 1;
34652         }
34653         return ret_ref;
34654 }
34655
34656 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
34657         LDKTxCreationKeys obj_conv;
34658         obj_conv.inner = (void*)(obj & (~1));
34659         obj_conv.is_owned = false;
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34661         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
34662         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34663         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34664         CVec_u8Z_free(ret_var);
34665         return ret_arr;
34666 }
34667
34668 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
34669         LDKu8slice ser_ref;
34670         ser_ref.datalen = ser->arr_len;
34671         ser_ref.data = ser->elems;
34672         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
34673         *ret_conv = TxCreationKeys_read(ser_ref);
34674         FREE(ser);
34675         return (uint32_t)ret_conv;
34676 }
34677
34678 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
34679         LDKChannelPublicKeys this_obj_conv;
34680         this_obj_conv.inner = (void*)(this_obj & (~1));
34681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34683         ChannelPublicKeys_free(this_obj_conv);
34684 }
34685
34686 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
34687         LDKChannelPublicKeys this_ptr_conv;
34688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34689         this_ptr_conv.is_owned = false;
34690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34691         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34692         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
34693         return ret_arr;
34694 }
34695
34696 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
34697         LDKChannelPublicKeys this_ptr_conv;
34698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34699         this_ptr_conv.is_owned = false;
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34701         LDKPublicKey val_ref;
34702         CHECK(val->arr_len == 33);
34703         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34704         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
34705 }
34706
34707 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
34708         LDKChannelPublicKeys this_ptr_conv;
34709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34710         this_ptr_conv.is_owned = false;
34711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34712         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34713         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
34714         return ret_arr;
34715 }
34716
34717 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
34718         LDKChannelPublicKeys this_ptr_conv;
34719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34720         this_ptr_conv.is_owned = false;
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34722         LDKPublicKey val_ref;
34723         CHECK(val->arr_len == 33);
34724         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34725         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
34726 }
34727
34728 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
34729         LDKChannelPublicKeys this_ptr_conv;
34730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34731         this_ptr_conv.is_owned = false;
34732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34733         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34734         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
34735         return ret_arr;
34736 }
34737
34738 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
34739         LDKChannelPublicKeys this_ptr_conv;
34740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34741         this_ptr_conv.is_owned = false;
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34743         LDKPublicKey val_ref;
34744         CHECK(val->arr_len == 33);
34745         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34746         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
34747 }
34748
34749 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
34750         LDKChannelPublicKeys this_ptr_conv;
34751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34752         this_ptr_conv.is_owned = false;
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34754         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34755         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
34756         return ret_arr;
34757 }
34758
34759 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
34760         LDKChannelPublicKeys this_ptr_conv;
34761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34762         this_ptr_conv.is_owned = false;
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34764         LDKPublicKey val_ref;
34765         CHECK(val->arr_len == 33);
34766         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34767         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34768 }
34769
34770 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
34771         LDKChannelPublicKeys this_ptr_conv;
34772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34773         this_ptr_conv.is_owned = false;
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34775         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34776         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
34777         return ret_arr;
34778 }
34779
34780 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
34781         LDKChannelPublicKeys this_ptr_conv;
34782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34783         this_ptr_conv.is_owned = false;
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34785         LDKPublicKey val_ref;
34786         CHECK(val->arr_len == 33);
34787         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34788         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
34789 }
34790
34791 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) {
34792         LDKPublicKey funding_pubkey_arg_ref;
34793         CHECK(funding_pubkey_arg->arr_len == 33);
34794         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
34795         LDKPublicKey revocation_basepoint_arg_ref;
34796         CHECK(revocation_basepoint_arg->arr_len == 33);
34797         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
34798         LDKPublicKey payment_point_arg_ref;
34799         CHECK(payment_point_arg->arr_len == 33);
34800         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
34801         LDKPublicKey delayed_payment_basepoint_arg_ref;
34802         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
34803         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
34804         LDKPublicKey htlc_basepoint_arg_ref;
34805         CHECK(htlc_basepoint_arg->arr_len == 33);
34806         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
34807         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);
34808         uint32_t ret_ref = 0;
34809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34812         ret_ref = (uintptr_t)ret_var.inner;
34813         if (ret_var.is_owned) {
34814                 ret_ref |= 1;
34815         }
34816         return ret_ref;
34817 }
34818
34819 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
34820         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
34821 uint32_t ret_ref = 0;
34822 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34823 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34824 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34825 ret_ref = (uintptr_t)ret_var.inner;
34826 if (ret_var.is_owned) {
34827         ret_ref |= 1;
34828 }
34829         return ret_ref;
34830 }
34831 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
34832         LDKChannelPublicKeys arg_conv;
34833         arg_conv.inner = (void*)(arg & (~1));
34834         arg_conv.is_owned = false;
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34836         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
34837         return ret_conv;
34838 }
34839
34840 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
34841         LDKChannelPublicKeys orig_conv;
34842         orig_conv.inner = (void*)(orig & (~1));
34843         orig_conv.is_owned = false;
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34845         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
34846         uint32_t ret_ref = 0;
34847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34850         ret_ref = (uintptr_t)ret_var.inner;
34851         if (ret_var.is_owned) {
34852                 ret_ref |= 1;
34853         }
34854         return ret_ref;
34855 }
34856
34857 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
34858         LDKChannelPublicKeys obj_conv;
34859         obj_conv.inner = (void*)(obj & (~1));
34860         obj_conv.is_owned = false;
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34862         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
34863         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34864         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34865         CVec_u8Z_free(ret_var);
34866         return ret_arr;
34867 }
34868
34869 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
34870         LDKu8slice ser_ref;
34871         ser_ref.datalen = ser->arr_len;
34872         ser_ref.data = ser->elems;
34873         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
34874         *ret_conv = ChannelPublicKeys_read(ser_ref);
34875         FREE(ser);
34876         return (uint32_t)ret_conv;
34877 }
34878
34879 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) {
34880         LDKPublicKey per_commitment_point_ref;
34881         CHECK(per_commitment_point->arr_len == 33);
34882         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34883         LDKPublicKey broadcaster_delayed_payment_base_ref;
34884         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
34885         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
34886         LDKPublicKey broadcaster_htlc_base_ref;
34887         CHECK(broadcaster_htlc_base->arr_len == 33);
34888         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
34889         LDKPublicKey countersignatory_revocation_base_ref;
34890         CHECK(countersignatory_revocation_base->arr_len == 33);
34891         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
34892         LDKPublicKey countersignatory_htlc_base_ref;
34893         CHECK(countersignatory_htlc_base->arr_len == 33);
34894         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
34895         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34896         *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);
34897         return (uint32_t)ret_conv;
34898 }
34899
34900 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) {
34901         LDKPublicKey per_commitment_point_ref;
34902         CHECK(per_commitment_point->arr_len == 33);
34903         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34904         LDKChannelPublicKeys broadcaster_keys_conv;
34905         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34906         broadcaster_keys_conv.is_owned = false;
34907         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34908         LDKChannelPublicKeys countersignatory_keys_conv;
34909         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34910         countersignatory_keys_conv.is_owned = false;
34911         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34912         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34913         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
34914         return (uint32_t)ret_conv;
34915 }
34916
34917 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) {
34918         LDKPublicKey revocation_key_ref;
34919         CHECK(revocation_key->arr_len == 33);
34920         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
34921         LDKPublicKey broadcaster_delayed_payment_key_ref;
34922         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
34923         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
34924         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
34925         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34926         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34927         CVec_u8Z_free(ret_var);
34928         return ret_arr;
34929 }
34930
34931 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
34932         LDKHTLCOutputInCommitment this_obj_conv;
34933         this_obj_conv.inner = (void*)(this_obj & (~1));
34934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34936         HTLCOutputInCommitment_free(this_obj_conv);
34937 }
34938
34939 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
34940         LDKHTLCOutputInCommitment this_ptr_conv;
34941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34942         this_ptr_conv.is_owned = false;
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34944         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
34945         return ret_conv;
34946 }
34947
34948 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
34949         LDKHTLCOutputInCommitment this_ptr_conv;
34950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34951         this_ptr_conv.is_owned = false;
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34953         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
34954 }
34955
34956 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
34957         LDKHTLCOutputInCommitment this_ptr_conv;
34958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34959         this_ptr_conv.is_owned = false;
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34961         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
34962         return ret_conv;
34963 }
34964
34965 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
34966         LDKHTLCOutputInCommitment this_ptr_conv;
34967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34968         this_ptr_conv.is_owned = false;
34969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34970         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
34971 }
34972
34973 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
34974         LDKHTLCOutputInCommitment this_ptr_conv;
34975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34976         this_ptr_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34978         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
34979         return ret_conv;
34980 }
34981
34982 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
34983         LDKHTLCOutputInCommitment this_ptr_conv;
34984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34985         this_ptr_conv.is_owned = false;
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34987         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
34988 }
34989
34990 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
34991         LDKHTLCOutputInCommitment this_ptr_conv;
34992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34993         this_ptr_conv.is_owned = false;
34994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34995         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34996         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
34997         return ret_arr;
34998 }
34999
35000 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
35001         LDKHTLCOutputInCommitment this_ptr_conv;
35002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35003         this_ptr_conv.is_owned = false;
35004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35005         LDKThirtyTwoBytes val_ref;
35006         CHECK(val->arr_len == 32);
35007         memcpy(val_ref.data, val->elems, 32); FREE(val);
35008         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35009 }
35010
35011 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
35012         LDKHTLCOutputInCommitment this_ptr_conv;
35013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35014         this_ptr_conv.is_owned = false;
35015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35016         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35017         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35018         uint32_t ret_ref = (uintptr_t)ret_copy;
35019         return ret_ref;
35020 }
35021
35022 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
35023         LDKHTLCOutputInCommitment this_ptr_conv;
35024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35025         this_ptr_conv.is_owned = false;
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35027         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35028         CHECK_ACCESS(val_ptr);
35029         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35030         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
35031         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35032 }
35033
35034 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) {
35035         LDKThirtyTwoBytes payment_hash_arg_ref;
35036         CHECK(payment_hash_arg->arr_len == 32);
35037         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35038         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
35039         CHECK_ACCESS(transaction_output_index_arg_ptr);
35040         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35041         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
35042         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35043         uint32_t ret_ref = 0;
35044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35047         ret_ref = (uintptr_t)ret_var.inner;
35048         if (ret_var.is_owned) {
35049                 ret_ref |= 1;
35050         }
35051         return ret_ref;
35052 }
35053
35054 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35055         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35056 uint32_t ret_ref = 0;
35057 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35058 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35059 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35060 ret_ref = (uintptr_t)ret_var.inner;
35061 if (ret_var.is_owned) {
35062         ret_ref |= 1;
35063 }
35064         return ret_ref;
35065 }
35066 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
35067         LDKHTLCOutputInCommitment arg_conv;
35068         arg_conv.inner = (void*)(arg & (~1));
35069         arg_conv.is_owned = false;
35070         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35071         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35072         return ret_conv;
35073 }
35074
35075 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
35076         LDKHTLCOutputInCommitment orig_conv;
35077         orig_conv.inner = (void*)(orig & (~1));
35078         orig_conv.is_owned = false;
35079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35080         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35081         uint32_t ret_ref = 0;
35082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35085         ret_ref = (uintptr_t)ret_var.inner;
35086         if (ret_var.is_owned) {
35087                 ret_ref |= 1;
35088         }
35089         return ret_ref;
35090 }
35091
35092 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
35093         LDKHTLCOutputInCommitment obj_conv;
35094         obj_conv.inner = (void*)(obj & (~1));
35095         obj_conv.is_owned = false;
35096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35097         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35098         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35099         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35100         CVec_u8Z_free(ret_var);
35101         return ret_arr;
35102 }
35103
35104 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35105         LDKu8slice ser_ref;
35106         ser_ref.datalen = ser->arr_len;
35107         ser_ref.data = ser->elems;
35108         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35109         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35110         FREE(ser);
35111         return (uint32_t)ret_conv;
35112 }
35113
35114 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
35115         LDKHTLCOutputInCommitment htlc_conv;
35116         htlc_conv.inner = (void*)(htlc & (~1));
35117         htlc_conv.is_owned = false;
35118         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35119         LDKTxCreationKeys keys_conv;
35120         keys_conv.inner = (void*)(keys & (~1));
35121         keys_conv.is_owned = false;
35122         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35123         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35124         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35125         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35126         CVec_u8Z_free(ret_var);
35127         return ret_arr;
35128 }
35129
35130 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35131         LDKPublicKey broadcaster_ref;
35132         CHECK(broadcaster->arr_len == 33);
35133         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35134         LDKPublicKey countersignatory_ref;
35135         CHECK(countersignatory->arr_len == 33);
35136         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35137         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35138         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35139         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35140         CVec_u8Z_free(ret_var);
35141         return ret_arr;
35142 }
35143
35144 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) {
35145         unsigned char commitment_txid_arr[32];
35146         CHECK(commitment_txid->arr_len == 32);
35147         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35148         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35149         LDKHTLCOutputInCommitment htlc_conv;
35150         htlc_conv.inner = (void*)(htlc & (~1));
35151         htlc_conv.is_owned = false;
35152         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35153         LDKPublicKey broadcaster_delayed_payment_key_ref;
35154         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35155         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35156         LDKPublicKey revocation_key_ref;
35157         CHECK(revocation_key->arr_len == 33);
35158         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35159         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);
35160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35162         Transaction_free(ret_var);
35163         return ret_arr;
35164 }
35165
35166 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35167         LDKPublicKey funding_pubkey_ref;
35168         CHECK(funding_pubkey->arr_len == 33);
35169         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35170         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35171         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35172         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35173         CVec_u8Z_free(ret_var);
35174         return ret_arr;
35175 }
35176
35177 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
35178         LDKChannelTransactionParameters this_obj_conv;
35179         this_obj_conv.inner = (void*)(this_obj & (~1));
35180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35182         ChannelTransactionParameters_free(this_obj_conv);
35183 }
35184
35185 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
35186         LDKChannelTransactionParameters this_ptr_conv;
35187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35188         this_ptr_conv.is_owned = false;
35189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35190         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35191         uint32_t ret_ref = 0;
35192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35195         ret_ref = (uintptr_t)ret_var.inner;
35196         if (ret_var.is_owned) {
35197                 ret_ref |= 1;
35198         }
35199         return ret_ref;
35200 }
35201
35202 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
35203         LDKChannelTransactionParameters 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         LDKChannelPublicKeys val_conv;
35208         val_conv.inner = (void*)(val & (~1));
35209         val_conv.is_owned = (val & 1) || (val == 0);
35210         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35211         val_conv = ChannelPublicKeys_clone(&val_conv);
35212         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
35213 }
35214
35215 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
35216         LDKChannelTransactionParameters this_ptr_conv;
35217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35218         this_ptr_conv.is_owned = false;
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
35221         return ret_conv;
35222 }
35223
35224 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) {
35225         LDKChannelTransactionParameters this_ptr_conv;
35226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35227         this_ptr_conv.is_owned = false;
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35229         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
35230 }
35231
35232 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
35233         LDKChannelTransactionParameters this_ptr_conv;
35234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35235         this_ptr_conv.is_owned = false;
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35237         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
35238         return ret_conv;
35239 }
35240
35241 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
35242         LDKChannelTransactionParameters this_ptr_conv;
35243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35244         this_ptr_conv.is_owned = false;
35245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35246         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
35247 }
35248
35249 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
35250         LDKChannelTransactionParameters this_ptr_conv;
35251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35252         this_ptr_conv.is_owned = false;
35253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35254         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
35255         uint32_t ret_ref = 0;
35256         if ((uintptr_t)ret_var.inner > 4096) {
35257                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35258                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35260                 ret_ref = (uintptr_t)ret_var.inner;
35261                 if (ret_var.is_owned) {
35262                         ret_ref |= 1;
35263                 }
35264         }
35265         return ret_ref;
35266 }
35267
35268 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
35269         LDKChannelTransactionParameters this_ptr_conv;
35270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35271         this_ptr_conv.is_owned = false;
35272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35273         LDKCounterpartyChannelTransactionParameters val_conv;
35274         val_conv.inner = (void*)(val & (~1));
35275         val_conv.is_owned = (val & 1) || (val == 0);
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35277         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
35278         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
35279 }
35280
35281 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
35282         LDKChannelTransactionParameters this_ptr_conv;
35283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35284         this_ptr_conv.is_owned = false;
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35286         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
35287         uint32_t ret_ref = 0;
35288         if ((uintptr_t)ret_var.inner > 4096) {
35289                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35290                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35292                 ret_ref = (uintptr_t)ret_var.inner;
35293                 if (ret_var.is_owned) {
35294                         ret_ref |= 1;
35295                 }
35296         }
35297         return ret_ref;
35298 }
35299
35300 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
35301         LDKChannelTransactionParameters this_ptr_conv;
35302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35303         this_ptr_conv.is_owned = false;
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35305         LDKOutPoint val_conv;
35306         val_conv.inner = (void*)(val & (~1));
35307         val_conv.is_owned = (val & 1) || (val == 0);
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35309         val_conv = OutPoint_clone(&val_conv);
35310         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
35311 }
35312
35313 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
35314         LDKChannelTransactionParameters this_ptr_conv;
35315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35316         this_ptr_conv.is_owned = false;
35317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35318         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
35319         return ret_conv;
35320 }
35321
35322 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
35323         LDKChannelTransactionParameters this_ptr_conv;
35324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35325         this_ptr_conv.is_owned = false;
35326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35327         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
35328         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
35329 }
35330
35331 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) {
35332         LDKChannelPublicKeys holder_pubkeys_arg_conv;
35333         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
35334         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
35335         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
35336         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
35337         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
35338         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
35339         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
35340         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
35341         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
35342         LDKOutPoint funding_outpoint_arg_conv;
35343         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
35344         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
35345         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
35346         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
35347         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
35348         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);
35349         uint32_t ret_ref = 0;
35350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35353         ret_ref = (uintptr_t)ret_var.inner;
35354         if (ret_var.is_owned) {
35355                 ret_ref |= 1;
35356         }
35357         return ret_ref;
35358 }
35359
35360 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
35361         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
35362 uint32_t ret_ref = 0;
35363 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35364 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35365 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35366 ret_ref = (uintptr_t)ret_var.inner;
35367 if (ret_var.is_owned) {
35368         ret_ref |= 1;
35369 }
35370         return ret_ref;
35371 }
35372 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
35373         LDKChannelTransactionParameters arg_conv;
35374         arg_conv.inner = (void*)(arg & (~1));
35375         arg_conv.is_owned = false;
35376         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35377         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
35378         return ret_conv;
35379 }
35380
35381 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
35382         LDKChannelTransactionParameters orig_conv;
35383         orig_conv.inner = (void*)(orig & (~1));
35384         orig_conv.is_owned = false;
35385         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35386         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
35387         uint32_t ret_ref = 0;
35388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35391         ret_ref = (uintptr_t)ret_var.inner;
35392         if (ret_var.is_owned) {
35393                 ret_ref |= 1;
35394         }
35395         return ret_ref;
35396 }
35397
35398 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
35399         LDKCounterpartyChannelTransactionParameters this_obj_conv;
35400         this_obj_conv.inner = (void*)(this_obj & (~1));
35401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35403         CounterpartyChannelTransactionParameters_free(this_obj_conv);
35404 }
35405
35406 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
35407         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35409         this_ptr_conv.is_owned = false;
35410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35411         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
35412         uint32_t ret_ref = 0;
35413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35416         ret_ref = (uintptr_t)ret_var.inner;
35417         if (ret_var.is_owned) {
35418                 ret_ref |= 1;
35419         }
35420         return ret_ref;
35421 }
35422
35423 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
35424         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35426         this_ptr_conv.is_owned = false;
35427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35428         LDKChannelPublicKeys val_conv;
35429         val_conv.inner = (void*)(val & (~1));
35430         val_conv.is_owned = (val & 1) || (val == 0);
35431         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35432         val_conv = ChannelPublicKeys_clone(&val_conv);
35433         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
35434 }
35435
35436 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
35437         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35439         this_ptr_conv.is_owned = false;
35440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35441         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
35442         return ret_conv;
35443 }
35444
35445 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
35446         LDKCounterpartyChannelTransactionParameters 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         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
35451 }
35452
35453 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
35454         LDKChannelPublicKeys pubkeys_arg_conv;
35455         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
35456         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
35457         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
35458         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
35459         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
35460         uint32_t ret_ref = 0;
35461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35464         ret_ref = (uintptr_t)ret_var.inner;
35465         if (ret_var.is_owned) {
35466                 ret_ref |= 1;
35467         }
35468         return ret_ref;
35469 }
35470
35471 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
35472         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
35473 uint32_t ret_ref = 0;
35474 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35475 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35476 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35477 ret_ref = (uintptr_t)ret_var.inner;
35478 if (ret_var.is_owned) {
35479         ret_ref |= 1;
35480 }
35481         return ret_ref;
35482 }
35483 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
35484         LDKCounterpartyChannelTransactionParameters arg_conv;
35485         arg_conv.inner = (void*)(arg & (~1));
35486         arg_conv.is_owned = false;
35487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35488         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
35489         return ret_conv;
35490 }
35491
35492 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
35493         LDKCounterpartyChannelTransactionParameters orig_conv;
35494         orig_conv.inner = (void*)(orig & (~1));
35495         orig_conv.is_owned = false;
35496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35497         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
35498         uint32_t ret_ref = 0;
35499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35502         ret_ref = (uintptr_t)ret_var.inner;
35503         if (ret_var.is_owned) {
35504                 ret_ref |= 1;
35505         }
35506         return ret_ref;
35507 }
35508
35509 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
35510         LDKChannelTransactionParameters this_arg_conv;
35511         this_arg_conv.inner = (void*)(this_arg & (~1));
35512         this_arg_conv.is_owned = false;
35513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35514         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
35515         return ret_conv;
35516 }
35517
35518 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
35519         LDKChannelTransactionParameters this_arg_conv;
35520         this_arg_conv.inner = (void*)(this_arg & (~1));
35521         this_arg_conv.is_owned = false;
35522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35523         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
35524         uint32_t ret_ref = 0;
35525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35528         ret_ref = (uintptr_t)ret_var.inner;
35529         if (ret_var.is_owned) {
35530                 ret_ref |= 1;
35531         }
35532         return ret_ref;
35533 }
35534
35535 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
35536         LDKChannelTransactionParameters this_arg_conv;
35537         this_arg_conv.inner = (void*)(this_arg & (~1));
35538         this_arg_conv.is_owned = false;
35539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35540         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
35541         uint32_t ret_ref = 0;
35542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35545         ret_ref = (uintptr_t)ret_var.inner;
35546         if (ret_var.is_owned) {
35547                 ret_ref |= 1;
35548         }
35549         return ret_ref;
35550 }
35551
35552 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
35553         LDKCounterpartyChannelTransactionParameters obj_conv;
35554         obj_conv.inner = (void*)(obj & (~1));
35555         obj_conv.is_owned = false;
35556         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35557         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
35558         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35559         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35560         CVec_u8Z_free(ret_var);
35561         return ret_arr;
35562 }
35563
35564 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
35565         LDKu8slice ser_ref;
35566         ser_ref.datalen = ser->arr_len;
35567         ser_ref.data = ser->elems;
35568         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
35569         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
35570         FREE(ser);
35571         return (uint32_t)ret_conv;
35572 }
35573
35574 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
35575         LDKChannelTransactionParameters obj_conv;
35576         obj_conv.inner = (void*)(obj & (~1));
35577         obj_conv.is_owned = false;
35578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35579         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
35580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35582         CVec_u8Z_free(ret_var);
35583         return ret_arr;
35584 }
35585
35586 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
35587         LDKu8slice ser_ref;
35588         ser_ref.datalen = ser->arr_len;
35589         ser_ref.data = ser->elems;
35590         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
35591         *ret_conv = ChannelTransactionParameters_read(ser_ref);
35592         FREE(ser);
35593         return (uint32_t)ret_conv;
35594 }
35595
35596 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
35597         LDKDirectedChannelTransactionParameters this_obj_conv;
35598         this_obj_conv.inner = (void*)(this_obj & (~1));
35599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35601         DirectedChannelTransactionParameters_free(this_obj_conv);
35602 }
35603
35604 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
35605         LDKDirectedChannelTransactionParameters this_arg_conv;
35606         this_arg_conv.inner = (void*)(this_arg & (~1));
35607         this_arg_conv.is_owned = false;
35608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35609         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
35610         uint32_t ret_ref = 0;
35611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35614         ret_ref = (uintptr_t)ret_var.inner;
35615         if (ret_var.is_owned) {
35616                 ret_ref |= 1;
35617         }
35618         return ret_ref;
35619 }
35620
35621 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
35622         LDKDirectedChannelTransactionParameters this_arg_conv;
35623         this_arg_conv.inner = (void*)(this_arg & (~1));
35624         this_arg_conv.is_owned = false;
35625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35626         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
35627         uint32_t ret_ref = 0;
35628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35631         ret_ref = (uintptr_t)ret_var.inner;
35632         if (ret_var.is_owned) {
35633                 ret_ref |= 1;
35634         }
35635         return ret_ref;
35636 }
35637
35638 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
35639         LDKDirectedChannelTransactionParameters this_arg_conv;
35640         this_arg_conv.inner = (void*)(this_arg & (~1));
35641         this_arg_conv.is_owned = false;
35642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35643         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
35644         return ret_conv;
35645 }
35646
35647 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
35648         LDKDirectedChannelTransactionParameters this_arg_conv;
35649         this_arg_conv.inner = (void*)(this_arg & (~1));
35650         this_arg_conv.is_owned = false;
35651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35652         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
35653         return ret_conv;
35654 }
35655
35656 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
35657         LDKDirectedChannelTransactionParameters this_arg_conv;
35658         this_arg_conv.inner = (void*)(this_arg & (~1));
35659         this_arg_conv.is_owned = false;
35660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35661         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
35662         uint32_t ret_ref = 0;
35663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35666         ret_ref = (uintptr_t)ret_var.inner;
35667         if (ret_var.is_owned) {
35668                 ret_ref |= 1;
35669         }
35670         return ret_ref;
35671 }
35672
35673 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
35674         LDKDirectedChannelTransactionParameters this_arg_conv;
35675         this_arg_conv.inner = (void*)(this_arg & (~1));
35676         this_arg_conv.is_owned = false;
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35678         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
35679         return ret_conv;
35680 }
35681
35682 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
35683         LDKHolderCommitmentTransaction this_obj_conv;
35684         this_obj_conv.inner = (void*)(this_obj & (~1));
35685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35687         HolderCommitmentTransaction_free(this_obj_conv);
35688 }
35689
35690 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
35691         LDKHolderCommitmentTransaction this_ptr_conv;
35692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35693         this_ptr_conv.is_owned = false;
35694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35695         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35696         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
35697         return ret_arr;
35698 }
35699
35700 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
35701         LDKHolderCommitmentTransaction this_ptr_conv;
35702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35703         this_ptr_conv.is_owned = false;
35704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35705         LDKSignature val_ref;
35706         CHECK(val->arr_len == 64);
35707         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
35708         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
35709 }
35710
35711 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
35712         LDKHolderCommitmentTransaction this_ptr_conv;
35713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35714         this_ptr_conv.is_owned = false;
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35716         LDKCVec_SignatureZ val_constr;
35717         val_constr.datalen = val->arr_len;
35718         if (val_constr.datalen > 0)
35719                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35720         else
35721                 val_constr.data = NULL;
35722         int8_tArray* val_vals = (void*) val->elems;
35723         for (size_t m = 0; m < val_constr.datalen; m++) {
35724                 int8_tArray val_conv_12 = val_vals[m];
35725                 LDKSignature val_conv_12_ref;
35726                 CHECK(val_conv_12->arr_len == 64);
35727                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
35728                 val_constr.data[m] = val_conv_12_ref;
35729         }
35730         FREE(val);
35731         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
35732 }
35733
35734 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
35735         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
35736 uint32_t ret_ref = 0;
35737 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35738 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35739 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35740 ret_ref = (uintptr_t)ret_var.inner;
35741 if (ret_var.is_owned) {
35742         ret_ref |= 1;
35743 }
35744         return ret_ref;
35745 }
35746 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
35747         LDKHolderCommitmentTransaction arg_conv;
35748         arg_conv.inner = (void*)(arg & (~1));
35749         arg_conv.is_owned = false;
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35751         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
35752         return ret_conv;
35753 }
35754
35755 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
35756         LDKHolderCommitmentTransaction orig_conv;
35757         orig_conv.inner = (void*)(orig & (~1));
35758         orig_conv.is_owned = false;
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35760         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
35761         uint32_t ret_ref = 0;
35762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35765         ret_ref = (uintptr_t)ret_var.inner;
35766         if (ret_var.is_owned) {
35767                 ret_ref |= 1;
35768         }
35769         return ret_ref;
35770 }
35771
35772 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
35773         LDKHolderCommitmentTransaction obj_conv;
35774         obj_conv.inner = (void*)(obj & (~1));
35775         obj_conv.is_owned = false;
35776         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35777         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
35778         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35779         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35780         CVec_u8Z_free(ret_var);
35781         return ret_arr;
35782 }
35783
35784 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
35785         LDKu8slice ser_ref;
35786         ser_ref.datalen = ser->arr_len;
35787         ser_ref.data = ser->elems;
35788         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
35789         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
35790         FREE(ser);
35791         return (uint32_t)ret_conv;
35792 }
35793
35794 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) {
35795         LDKCommitmentTransaction commitment_tx_conv;
35796         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
35797         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
35799         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
35800         LDKSignature counterparty_sig_ref;
35801         CHECK(counterparty_sig->arr_len == 64);
35802         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
35803         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
35804         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
35805         if (counterparty_htlc_sigs_constr.datalen > 0)
35806                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35807         else
35808                 counterparty_htlc_sigs_constr.data = NULL;
35809         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
35810         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
35811                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
35812                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
35813                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
35814                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
35815                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
35816         }
35817         FREE(counterparty_htlc_sigs);
35818         LDKPublicKey holder_funding_key_ref;
35819         CHECK(holder_funding_key->arr_len == 33);
35820         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
35821         LDKPublicKey counterparty_funding_key_ref;
35822         CHECK(counterparty_funding_key->arr_len == 33);
35823         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
35824         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
35825         uint32_t ret_ref = 0;
35826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35829         ret_ref = (uintptr_t)ret_var.inner;
35830         if (ret_var.is_owned) {
35831                 ret_ref |= 1;
35832         }
35833         return ret_ref;
35834 }
35835
35836 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
35837         LDKBuiltCommitmentTransaction this_obj_conv;
35838         this_obj_conv.inner = (void*)(this_obj & (~1));
35839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35841         BuiltCommitmentTransaction_free(this_obj_conv);
35842 }
35843
35844 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
35845         LDKBuiltCommitmentTransaction this_ptr_conv;
35846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35847         this_ptr_conv.is_owned = false;
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35849         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
35850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35852         Transaction_free(ret_var);
35853         return ret_arr;
35854 }
35855
35856 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
35857         LDKBuiltCommitmentTransaction this_ptr_conv;
35858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35859         this_ptr_conv.is_owned = false;
35860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35861         LDKTransaction val_ref;
35862         val_ref.datalen = val->arr_len;
35863         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
35864         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35865         val_ref.data_is_owned = true;
35866         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
35867 }
35868
35869 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
35870         LDKBuiltCommitmentTransaction this_ptr_conv;
35871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35872         this_ptr_conv.is_owned = false;
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35874         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35875         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
35876         return ret_arr;
35877 }
35878
35879 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
35880         LDKBuiltCommitmentTransaction this_ptr_conv;
35881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35882         this_ptr_conv.is_owned = false;
35883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35884         LDKThirtyTwoBytes val_ref;
35885         CHECK(val->arr_len == 32);
35886         memcpy(val_ref.data, val->elems, 32); FREE(val);
35887         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
35888 }
35889
35890 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
35891         LDKTransaction transaction_arg_ref;
35892         transaction_arg_ref.datalen = transaction_arg->arr_len;
35893         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
35894         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
35895         transaction_arg_ref.data_is_owned = true;
35896         LDKThirtyTwoBytes txid_arg_ref;
35897         CHECK(txid_arg->arr_len == 32);
35898         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
35899         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
35900         uint32_t ret_ref = 0;
35901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35904         ret_ref = (uintptr_t)ret_var.inner;
35905         if (ret_var.is_owned) {
35906                 ret_ref |= 1;
35907         }
35908         return ret_ref;
35909 }
35910
35911 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
35912         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
35913 uint32_t ret_ref = 0;
35914 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35915 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35916 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35917 ret_ref = (uintptr_t)ret_var.inner;
35918 if (ret_var.is_owned) {
35919         ret_ref |= 1;
35920 }
35921         return ret_ref;
35922 }
35923 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
35924         LDKBuiltCommitmentTransaction arg_conv;
35925         arg_conv.inner = (void*)(arg & (~1));
35926         arg_conv.is_owned = false;
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35928         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
35929         return ret_conv;
35930 }
35931
35932 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
35933         LDKBuiltCommitmentTransaction orig_conv;
35934         orig_conv.inner = (void*)(orig & (~1));
35935         orig_conv.is_owned = false;
35936         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35937         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
35938         uint32_t ret_ref = 0;
35939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35942         ret_ref = (uintptr_t)ret_var.inner;
35943         if (ret_var.is_owned) {
35944                 ret_ref |= 1;
35945         }
35946         return ret_ref;
35947 }
35948
35949 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
35950         LDKBuiltCommitmentTransaction obj_conv;
35951         obj_conv.inner = (void*)(obj & (~1));
35952         obj_conv.is_owned = false;
35953         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35954         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
35955         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35956         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35957         CVec_u8Z_free(ret_var);
35958         return ret_arr;
35959 }
35960
35961 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
35962         LDKu8slice ser_ref;
35963         ser_ref.datalen = ser->arr_len;
35964         ser_ref.data = ser->elems;
35965         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
35966         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
35967         FREE(ser);
35968         return (uint32_t)ret_conv;
35969 }
35970
35971 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) {
35972         LDKBuiltCommitmentTransaction this_arg_conv;
35973         this_arg_conv.inner = (void*)(this_arg & (~1));
35974         this_arg_conv.is_owned = false;
35975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35976         LDKu8slice funding_redeemscript_ref;
35977         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35978         funding_redeemscript_ref.data = funding_redeemscript->elems;
35979         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35980         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
35981         FREE(funding_redeemscript);
35982         return ret_arr;
35983 }
35984
35985 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) {
35986         LDKBuiltCommitmentTransaction this_arg_conv;
35987         this_arg_conv.inner = (void*)(this_arg & (~1));
35988         this_arg_conv.is_owned = false;
35989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35990         unsigned char funding_key_arr[32];
35991         CHECK(funding_key->arr_len == 32);
35992         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
35993         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35994         LDKu8slice funding_redeemscript_ref;
35995         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35996         funding_redeemscript_ref.data = funding_redeemscript->elems;
35997         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35998         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
35999         FREE(funding_redeemscript);
36000         return ret_arr;
36001 }
36002
36003 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
36004         LDKClosingTransaction this_obj_conv;
36005         this_obj_conv.inner = (void*)(this_obj & (~1));
36006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36008         ClosingTransaction_free(this_obj_conv);
36009 }
36010
36011 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36012         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36013 uint32_t ret_ref = 0;
36014 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36015 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36016 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36017 ret_ref = (uintptr_t)ret_var.inner;
36018 if (ret_var.is_owned) {
36019         ret_ref |= 1;
36020 }
36021         return ret_ref;
36022 }
36023 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
36024         LDKClosingTransaction arg_conv;
36025         arg_conv.inner = (void*)(arg & (~1));
36026         arg_conv.is_owned = false;
36027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36028         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36029         return ret_conv;
36030 }
36031
36032 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
36033         LDKClosingTransaction orig_conv;
36034         orig_conv.inner = (void*)(orig & (~1));
36035         orig_conv.is_owned = false;
36036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36037         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36038         uint32_t ret_ref = 0;
36039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36042         ret_ref = (uintptr_t)ret_var.inner;
36043         if (ret_var.is_owned) {
36044                 ret_ref |= 1;
36045         }
36046         return ret_ref;
36047 }
36048
36049 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
36050         LDKClosingTransaction o_conv;
36051         o_conv.inner = (void*)(o & (~1));
36052         o_conv.is_owned = false;
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36054         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36055         return ret_conv;
36056 }
36057
36058 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) {
36059         LDKCVec_u8Z to_holder_script_ref;
36060         to_holder_script_ref.datalen = to_holder_script->arr_len;
36061         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36062         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36063         LDKCVec_u8Z to_counterparty_script_ref;
36064         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36065         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36066         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36067         LDKOutPoint funding_outpoint_conv;
36068         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36069         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36071         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36072         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36073         uint32_t ret_ref = 0;
36074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36077         ret_ref = (uintptr_t)ret_var.inner;
36078         if (ret_var.is_owned) {
36079                 ret_ref |= 1;
36080         }
36081         return ret_ref;
36082 }
36083
36084 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
36085         LDKClosingTransaction this_arg_conv;
36086         this_arg_conv.inner = (void*)(this_arg & (~1));
36087         this_arg_conv.is_owned = false;
36088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36089         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36090         uint32_t ret_ref = 0;
36091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36094         ret_ref = (uintptr_t)ret_var.inner;
36095         if (ret_var.is_owned) {
36096                 ret_ref |= 1;
36097         }
36098         return ret_ref;
36099 }
36100
36101 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
36102         LDKClosingTransaction this_arg_conv;
36103         this_arg_conv.inner = (void*)(this_arg & (~1));
36104         this_arg_conv.is_owned = false;
36105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36106         LDKOutPoint funding_outpoint_conv;
36107         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36108         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36109         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36110         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36111         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36112         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36113         return (uint32_t)ret_conv;
36114 }
36115
36116 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
36117         LDKClosingTransaction this_arg_conv;
36118         this_arg_conv.inner = (void*)(this_arg & (~1));
36119         this_arg_conv.is_owned = false;
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36121         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36122         return ret_conv;
36123 }
36124
36125 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
36126         LDKClosingTransaction this_arg_conv;
36127         this_arg_conv.inner = (void*)(this_arg & (~1));
36128         this_arg_conv.is_owned = false;
36129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36130         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36131         return ret_conv;
36132 }
36133
36134 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
36135         LDKClosingTransaction this_arg_conv;
36136         this_arg_conv.inner = (void*)(this_arg & (~1));
36137         this_arg_conv.is_owned = false;
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36139         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36140         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36141         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36142         return ret_arr;
36143 }
36144
36145 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
36146         LDKClosingTransaction this_arg_conv;
36147         this_arg_conv.inner = (void*)(this_arg & (~1));
36148         this_arg_conv.is_owned = false;
36149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36150         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36151         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36152         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36153         return ret_arr;
36154 }
36155
36156 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
36157         LDKTrustedClosingTransaction this_obj_conv;
36158         this_obj_conv.inner = (void*)(this_obj & (~1));
36159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36161         TrustedClosingTransaction_free(this_obj_conv);
36162 }
36163
36164 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
36165         LDKTrustedClosingTransaction this_arg_conv;
36166         this_arg_conv.inner = (void*)(this_arg & (~1));
36167         this_arg_conv.is_owned = false;
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36169         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36170         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36171         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36172         Transaction_free(ret_var);
36173         return ret_arr;
36174 }
36175
36176 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) {
36177         LDKTrustedClosingTransaction this_arg_conv;
36178         this_arg_conv.inner = (void*)(this_arg & (~1));
36179         this_arg_conv.is_owned = false;
36180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36181         LDKu8slice funding_redeemscript_ref;
36182         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36183         funding_redeemscript_ref.data = funding_redeemscript->elems;
36184         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36185         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36186         FREE(funding_redeemscript);
36187         return ret_arr;
36188 }
36189
36190 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) {
36191         LDKTrustedClosingTransaction this_arg_conv;
36192         this_arg_conv.inner = (void*)(this_arg & (~1));
36193         this_arg_conv.is_owned = false;
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36195         unsigned char funding_key_arr[32];
36196         CHECK(funding_key->arr_len == 32);
36197         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36198         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36199         LDKu8slice funding_redeemscript_ref;
36200         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36201         funding_redeemscript_ref.data = funding_redeemscript->elems;
36202         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36203         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36204         FREE(funding_redeemscript);
36205         return ret_arr;
36206 }
36207
36208 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
36209         LDKCommitmentTransaction this_obj_conv;
36210         this_obj_conv.inner = (void*)(this_obj & (~1));
36211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36213         CommitmentTransaction_free(this_obj_conv);
36214 }
36215
36216 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
36217         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
36218 uint32_t ret_ref = 0;
36219 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36220 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36221 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36222 ret_ref = (uintptr_t)ret_var.inner;
36223 if (ret_var.is_owned) {
36224         ret_ref |= 1;
36225 }
36226         return ret_ref;
36227 }
36228 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
36229         LDKCommitmentTransaction arg_conv;
36230         arg_conv.inner = (void*)(arg & (~1));
36231         arg_conv.is_owned = false;
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36233         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
36234         return ret_conv;
36235 }
36236
36237 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
36238         LDKCommitmentTransaction orig_conv;
36239         orig_conv.inner = (void*)(orig & (~1));
36240         orig_conv.is_owned = false;
36241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36242         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
36243         uint32_t ret_ref = 0;
36244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36247         ret_ref = (uintptr_t)ret_var.inner;
36248         if (ret_var.is_owned) {
36249                 ret_ref |= 1;
36250         }
36251         return ret_ref;
36252 }
36253
36254 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
36255         LDKCommitmentTransaction obj_conv;
36256         obj_conv.inner = (void*)(obj & (~1));
36257         obj_conv.is_owned = false;
36258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36259         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
36260         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36261         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36262         CVec_u8Z_free(ret_var);
36263         return ret_arr;
36264 }
36265
36266 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
36267         LDKu8slice ser_ref;
36268         ser_ref.datalen = ser->arr_len;
36269         ser_ref.data = ser->elems;
36270         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
36271         *ret_conv = CommitmentTransaction_read(ser_ref);
36272         FREE(ser);
36273         return (uint32_t)ret_conv;
36274 }
36275
36276 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
36277         LDKCommitmentTransaction this_arg_conv;
36278         this_arg_conv.inner = (void*)(this_arg & (~1));
36279         this_arg_conv.is_owned = false;
36280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36281         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
36282         return ret_conv;
36283 }
36284
36285 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
36286         LDKCommitmentTransaction this_arg_conv;
36287         this_arg_conv.inner = (void*)(this_arg & (~1));
36288         this_arg_conv.is_owned = false;
36289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36290         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
36291         return ret_conv;
36292 }
36293
36294 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
36295         LDKCommitmentTransaction this_arg_conv;
36296         this_arg_conv.inner = (void*)(this_arg & (~1));
36297         this_arg_conv.is_owned = false;
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36299         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
36300         return ret_conv;
36301 }
36302
36303 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
36304         LDKCommitmentTransaction this_arg_conv;
36305         this_arg_conv.inner = (void*)(this_arg & (~1));
36306         this_arg_conv.is_owned = false;
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36308         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
36309         return ret_conv;
36310 }
36311
36312 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
36313         LDKCommitmentTransaction this_arg_conv;
36314         this_arg_conv.inner = (void*)(this_arg & (~1));
36315         this_arg_conv.is_owned = false;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36317         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
36318         uint32_t ret_ref = 0;
36319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36322         ret_ref = (uintptr_t)ret_var.inner;
36323         if (ret_var.is_owned) {
36324                 ret_ref |= 1;
36325         }
36326         return ret_ref;
36327 }
36328
36329 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) {
36330         LDKCommitmentTransaction this_arg_conv;
36331         this_arg_conv.inner = (void*)(this_arg & (~1));
36332         this_arg_conv.is_owned = false;
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36334         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36335         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36336         channel_parameters_conv.is_owned = false;
36337         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36338         LDKChannelPublicKeys broadcaster_keys_conv;
36339         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
36340         broadcaster_keys_conv.is_owned = false;
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
36342         LDKChannelPublicKeys countersignatory_keys_conv;
36343         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
36344         countersignatory_keys_conv.is_owned = false;
36345         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
36346         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
36347         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
36348         return (uint32_t)ret_conv;
36349 }
36350
36351 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
36352         LDKTrustedCommitmentTransaction this_obj_conv;
36353         this_obj_conv.inner = (void*)(this_obj & (~1));
36354         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36356         TrustedCommitmentTransaction_free(this_obj_conv);
36357 }
36358
36359 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
36360         LDKTrustedCommitmentTransaction this_arg_conv;
36361         this_arg_conv.inner = (void*)(this_arg & (~1));
36362         this_arg_conv.is_owned = false;
36363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36364         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36365         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
36366         return ret_arr;
36367 }
36368
36369 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
36370         LDKTrustedCommitmentTransaction 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         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
36375         uint32_t ret_ref = 0;
36376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36379         ret_ref = (uintptr_t)ret_var.inner;
36380         if (ret_var.is_owned) {
36381                 ret_ref |= 1;
36382         }
36383         return ret_ref;
36384 }
36385
36386 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
36387         LDKTrustedCommitmentTransaction this_arg_conv;
36388         this_arg_conv.inner = (void*)(this_arg & (~1));
36389         this_arg_conv.is_owned = false;
36390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36391         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
36392         uint32_t ret_ref = 0;
36393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36396         ret_ref = (uintptr_t)ret_var.inner;
36397         if (ret_var.is_owned) {
36398                 ret_ref |= 1;
36399         }
36400         return ret_ref;
36401 }
36402
36403 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
36404         LDKTrustedCommitmentTransaction this_arg_conv;
36405         this_arg_conv.inner = (void*)(this_arg & (~1));
36406         this_arg_conv.is_owned = false;
36407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36408         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
36409         return ret_conv;
36410 }
36411
36412 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) {
36413         LDKTrustedCommitmentTransaction this_arg_conv;
36414         this_arg_conv.inner = (void*)(this_arg & (~1));
36415         this_arg_conv.is_owned = false;
36416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36417         unsigned char htlc_base_key_arr[32];
36418         CHECK(htlc_base_key->arr_len == 32);
36419         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
36420         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
36421         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36422         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36423         channel_parameters_conv.is_owned = false;
36424         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36425         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
36426         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
36427         return (uint32_t)ret_conv;
36428 }
36429
36430 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) {
36431         LDKPublicKey broadcaster_payment_basepoint_ref;
36432         CHECK(broadcaster_payment_basepoint->arr_len == 33);
36433         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
36434         LDKPublicKey countersignatory_payment_basepoint_ref;
36435         CHECK(countersignatory_payment_basepoint->arr_len == 33);
36436         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
36437         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
36438         return ret_conv;
36439 }
36440
36441 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
36442         LDKInitFeatures a_conv;
36443         a_conv.inner = (void*)(a & (~1));
36444         a_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36446         LDKInitFeatures b_conv;
36447         b_conv.inner = (void*)(b & (~1));
36448         b_conv.is_owned = false;
36449         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36450         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
36451         return ret_conv;
36452 }
36453
36454 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
36455         LDKNodeFeatures a_conv;
36456         a_conv.inner = (void*)(a & (~1));
36457         a_conv.is_owned = false;
36458         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36459         LDKNodeFeatures b_conv;
36460         b_conv.inner = (void*)(b & (~1));
36461         b_conv.is_owned = false;
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36463         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
36464         return ret_conv;
36465 }
36466
36467 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
36468         LDKChannelFeatures a_conv;
36469         a_conv.inner = (void*)(a & (~1));
36470         a_conv.is_owned = false;
36471         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36472         LDKChannelFeatures b_conv;
36473         b_conv.inner = (void*)(b & (~1));
36474         b_conv.is_owned = false;
36475         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36476         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
36477         return ret_conv;
36478 }
36479
36480 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
36481         LDKInvoiceFeatures a_conv;
36482         a_conv.inner = (void*)(a & (~1));
36483         a_conv.is_owned = false;
36484         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36485         LDKInvoiceFeatures b_conv;
36486         b_conv.inner = (void*)(b & (~1));
36487         b_conv.is_owned = false;
36488         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36489         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
36490         return ret_conv;
36491 }
36492
36493 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
36494         LDKChannelTypeFeatures a_conv;
36495         a_conv.inner = (void*)(a & (~1));
36496         a_conv.is_owned = false;
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36498         LDKChannelTypeFeatures b_conv;
36499         b_conv.inner = (void*)(b & (~1));
36500         b_conv.is_owned = false;
36501         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36502         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
36503         return ret_conv;
36504 }
36505
36506 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
36507         LDKInitFeatures ret_var = InitFeatures_clone(arg);
36508 uint32_t ret_ref = 0;
36509 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36510 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36511 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36512 ret_ref = (uintptr_t)ret_var.inner;
36513 if (ret_var.is_owned) {
36514         ret_ref |= 1;
36515 }
36516         return ret_ref;
36517 }
36518 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
36519         LDKInitFeatures arg_conv;
36520         arg_conv.inner = (void*)(arg & (~1));
36521         arg_conv.is_owned = false;
36522         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36523         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
36524         return ret_conv;
36525 }
36526
36527 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
36528         LDKInitFeatures orig_conv;
36529         orig_conv.inner = (void*)(orig & (~1));
36530         orig_conv.is_owned = false;
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36532         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
36533         uint32_t ret_ref = 0;
36534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36537         ret_ref = (uintptr_t)ret_var.inner;
36538         if (ret_var.is_owned) {
36539                 ret_ref |= 1;
36540         }
36541         return ret_ref;
36542 }
36543
36544 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
36545         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
36546 uint32_t ret_ref = 0;
36547 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36548 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36549 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36550 ret_ref = (uintptr_t)ret_var.inner;
36551 if (ret_var.is_owned) {
36552         ret_ref |= 1;
36553 }
36554         return ret_ref;
36555 }
36556 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
36557         LDKNodeFeatures arg_conv;
36558         arg_conv.inner = (void*)(arg & (~1));
36559         arg_conv.is_owned = false;
36560         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36561         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
36562         return ret_conv;
36563 }
36564
36565 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
36566         LDKNodeFeatures orig_conv;
36567         orig_conv.inner = (void*)(orig & (~1));
36568         orig_conv.is_owned = false;
36569         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36570         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
36571         uint32_t ret_ref = 0;
36572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36575         ret_ref = (uintptr_t)ret_var.inner;
36576         if (ret_var.is_owned) {
36577                 ret_ref |= 1;
36578         }
36579         return ret_ref;
36580 }
36581
36582 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
36583         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
36584 uint32_t ret_ref = 0;
36585 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36586 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36587 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36588 ret_ref = (uintptr_t)ret_var.inner;
36589 if (ret_var.is_owned) {
36590         ret_ref |= 1;
36591 }
36592         return ret_ref;
36593 }
36594 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
36595         LDKChannelFeatures arg_conv;
36596         arg_conv.inner = (void*)(arg & (~1));
36597         arg_conv.is_owned = false;
36598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36599         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
36600         return ret_conv;
36601 }
36602
36603 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
36604         LDKChannelFeatures orig_conv;
36605         orig_conv.inner = (void*)(orig & (~1));
36606         orig_conv.is_owned = false;
36607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36608         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
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
36620 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
36621         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
36622 uint32_t ret_ref = 0;
36623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36626 ret_ref = (uintptr_t)ret_var.inner;
36627 if (ret_var.is_owned) {
36628         ret_ref |= 1;
36629 }
36630         return ret_ref;
36631 }
36632 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
36633         LDKInvoiceFeatures arg_conv;
36634         arg_conv.inner = (void*)(arg & (~1));
36635         arg_conv.is_owned = false;
36636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36637         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
36638         return ret_conv;
36639 }
36640
36641 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
36642         LDKInvoiceFeatures orig_conv;
36643         orig_conv.inner = (void*)(orig & (~1));
36644         orig_conv.is_owned = false;
36645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36646         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
36647         uint32_t ret_ref = 0;
36648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36651         ret_ref = (uintptr_t)ret_var.inner;
36652         if (ret_var.is_owned) {
36653                 ret_ref |= 1;
36654         }
36655         return ret_ref;
36656 }
36657
36658 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
36659         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
36660 uint32_t ret_ref = 0;
36661 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36662 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36663 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36664 ret_ref = (uintptr_t)ret_var.inner;
36665 if (ret_var.is_owned) {
36666         ret_ref |= 1;
36667 }
36668         return ret_ref;
36669 }
36670 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
36671         LDKChannelTypeFeatures arg_conv;
36672         arg_conv.inner = (void*)(arg & (~1));
36673         arg_conv.is_owned = false;
36674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36675         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
36676         return ret_conv;
36677 }
36678
36679 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
36680         LDKChannelTypeFeatures orig_conv;
36681         orig_conv.inner = (void*)(orig & (~1));
36682         orig_conv.is_owned = false;
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36684         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
36685         uint32_t ret_ref = 0;
36686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36689         ret_ref = (uintptr_t)ret_var.inner;
36690         if (ret_var.is_owned) {
36691                 ret_ref |= 1;
36692         }
36693         return ret_ref;
36694 }
36695
36696 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
36697         LDKInitFeatures this_obj_conv;
36698         this_obj_conv.inner = (void*)(this_obj & (~1));
36699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36701         InitFeatures_free(this_obj_conv);
36702 }
36703
36704 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
36705         LDKNodeFeatures this_obj_conv;
36706         this_obj_conv.inner = (void*)(this_obj & (~1));
36707         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36709         NodeFeatures_free(this_obj_conv);
36710 }
36711
36712 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
36713         LDKChannelFeatures this_obj_conv;
36714         this_obj_conv.inner = (void*)(this_obj & (~1));
36715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36717         ChannelFeatures_free(this_obj_conv);
36718 }
36719
36720 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
36721         LDKInvoiceFeatures this_obj_conv;
36722         this_obj_conv.inner = (void*)(this_obj & (~1));
36723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36725         InvoiceFeatures_free(this_obj_conv);
36726 }
36727
36728 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
36729         LDKChannelTypeFeatures this_obj_conv;
36730         this_obj_conv.inner = (void*)(this_obj & (~1));
36731         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36733         ChannelTypeFeatures_free(this_obj_conv);
36734 }
36735
36736 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
36737         LDKInitFeatures ret_var = InitFeatures_empty();
36738         uint32_t ret_ref = 0;
36739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36742         ret_ref = (uintptr_t)ret_var.inner;
36743         if (ret_var.is_owned) {
36744                 ret_ref |= 1;
36745         }
36746         return ret_ref;
36747 }
36748
36749 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
36750         LDKInitFeatures ret_var = InitFeatures_known();
36751         uint32_t ret_ref = 0;
36752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36755         ret_ref = (uintptr_t)ret_var.inner;
36756         if (ret_var.is_owned) {
36757                 ret_ref |= 1;
36758         }
36759         return ret_ref;
36760 }
36761
36762 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
36763         LDKInitFeatures this_arg_conv;
36764         this_arg_conv.inner = (void*)(this_arg & (~1));
36765         this_arg_conv.is_owned = false;
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36767         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
36768         return ret_conv;
36769 }
36770
36771 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
36772         LDKNodeFeatures ret_var = NodeFeatures_empty();
36773         uint32_t ret_ref = 0;
36774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36777         ret_ref = (uintptr_t)ret_var.inner;
36778         if (ret_var.is_owned) {
36779                 ret_ref |= 1;
36780         }
36781         return ret_ref;
36782 }
36783
36784 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
36785         LDKNodeFeatures ret_var = NodeFeatures_known();
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 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
36798         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
36803         return ret_conv;
36804 }
36805
36806 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
36807         LDKChannelFeatures ret_var = ChannelFeatures_empty();
36808         uint32_t ret_ref = 0;
36809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36812         ret_ref = (uintptr_t)ret_var.inner;
36813         if (ret_var.is_owned) {
36814                 ret_ref |= 1;
36815         }
36816         return ret_ref;
36817 }
36818
36819 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
36820         LDKChannelFeatures ret_var = ChannelFeatures_known();
36821         uint32_t ret_ref = 0;
36822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36825         ret_ref = (uintptr_t)ret_var.inner;
36826         if (ret_var.is_owned) {
36827                 ret_ref |= 1;
36828         }
36829         return ret_ref;
36830 }
36831
36832 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
36833         LDKChannelFeatures this_arg_conv;
36834         this_arg_conv.inner = (void*)(this_arg & (~1));
36835         this_arg_conv.is_owned = false;
36836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36837         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
36838         return ret_conv;
36839 }
36840
36841 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
36842         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
36843         uint32_t ret_ref = 0;
36844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36847         ret_ref = (uintptr_t)ret_var.inner;
36848         if (ret_var.is_owned) {
36849                 ret_ref |= 1;
36850         }
36851         return ret_ref;
36852 }
36853
36854 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
36855         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
36856         uint32_t ret_ref = 0;
36857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36860         ret_ref = (uintptr_t)ret_var.inner;
36861         if (ret_var.is_owned) {
36862                 ret_ref |= 1;
36863         }
36864         return ret_ref;
36865 }
36866
36867 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
36868         LDKInvoiceFeatures this_arg_conv;
36869         this_arg_conv.inner = (void*)(this_arg & (~1));
36870         this_arg_conv.is_owned = false;
36871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36872         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
36873         return ret_conv;
36874 }
36875
36876 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
36877         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
36878         uint32_t ret_ref = 0;
36879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36882         ret_ref = (uintptr_t)ret_var.inner;
36883         if (ret_var.is_owned) {
36884                 ret_ref |= 1;
36885         }
36886         return ret_ref;
36887 }
36888
36889 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
36890         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
36891         uint32_t ret_ref = 0;
36892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36895         ret_ref = (uintptr_t)ret_var.inner;
36896         if (ret_var.is_owned) {
36897                 ret_ref |= 1;
36898         }
36899         return ret_ref;
36900 }
36901
36902 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
36903         LDKChannelTypeFeatures this_arg_conv;
36904         this_arg_conv.inner = (void*)(this_arg & (~1));
36905         this_arg_conv.is_owned = false;
36906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36907         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
36908         return ret_conv;
36909 }
36910
36911 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
36912         LDKInitFeatures obj_conv;
36913         obj_conv.inner = (void*)(obj & (~1));
36914         obj_conv.is_owned = false;
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36916         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
36917         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36918         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36919         CVec_u8Z_free(ret_var);
36920         return ret_arr;
36921 }
36922
36923 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
36924         LDKu8slice ser_ref;
36925         ser_ref.datalen = ser->arr_len;
36926         ser_ref.data = ser->elems;
36927         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
36928         *ret_conv = InitFeatures_read(ser_ref);
36929         FREE(ser);
36930         return (uint32_t)ret_conv;
36931 }
36932
36933 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
36934         LDKChannelFeatures obj_conv;
36935         obj_conv.inner = (void*)(obj & (~1));
36936         obj_conv.is_owned = false;
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36938         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
36939         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36940         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36941         CVec_u8Z_free(ret_var);
36942         return ret_arr;
36943 }
36944
36945 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
36946         LDKu8slice ser_ref;
36947         ser_ref.datalen = ser->arr_len;
36948         ser_ref.data = ser->elems;
36949         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
36950         *ret_conv = ChannelFeatures_read(ser_ref);
36951         FREE(ser);
36952         return (uint32_t)ret_conv;
36953 }
36954
36955 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
36956         LDKNodeFeatures obj_conv;
36957         obj_conv.inner = (void*)(obj & (~1));
36958         obj_conv.is_owned = false;
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36960         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
36961         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36962         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36963         CVec_u8Z_free(ret_var);
36964         return ret_arr;
36965 }
36966
36967 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
36968         LDKu8slice ser_ref;
36969         ser_ref.datalen = ser->arr_len;
36970         ser_ref.data = ser->elems;
36971         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
36972         *ret_conv = NodeFeatures_read(ser_ref);
36973         FREE(ser);
36974         return (uint32_t)ret_conv;
36975 }
36976
36977 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
36978         LDKInvoiceFeatures obj_conv;
36979         obj_conv.inner = (void*)(obj & (~1));
36980         obj_conv.is_owned = false;
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36982         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
36983         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36984         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36985         CVec_u8Z_free(ret_var);
36986         return ret_arr;
36987 }
36988
36989 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
36990         LDKu8slice ser_ref;
36991         ser_ref.datalen = ser->arr_len;
36992         ser_ref.data = ser->elems;
36993         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
36994         *ret_conv = InvoiceFeatures_read(ser_ref);
36995         FREE(ser);
36996         return (uint32_t)ret_conv;
36997 }
36998
36999 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
37000         LDKChannelTypeFeatures obj_conv;
37001         obj_conv.inner = (void*)(obj & (~1));
37002         obj_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37004         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37005         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37006         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37007         CVec_u8Z_free(ret_var);
37008         return ret_arr;
37009 }
37010
37011 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37012         LDKu8slice ser_ref;
37013         ser_ref.datalen = ser->arr_len;
37014         ser_ref.data = ser->elems;
37015         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37016         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37017         FREE(ser);
37018         return (uint32_t)ret_conv;
37019 }
37020
37021 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37022         LDKInitFeatures this_arg_conv;
37023         this_arg_conv.inner = (void*)(this_arg & (~1));
37024         this_arg_conv.is_owned = false;
37025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37026         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37027 }
37028
37029 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37030         LDKInitFeatures this_arg_conv;
37031         this_arg_conv.inner = (void*)(this_arg & (~1));
37032         this_arg_conv.is_owned = false;
37033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37034         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37035 }
37036
37037 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
37038         LDKInitFeatures this_arg_conv;
37039         this_arg_conv.inner = (void*)(this_arg & (~1));
37040         this_arg_conv.is_owned = false;
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37042         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37043         return ret_conv;
37044 }
37045
37046 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37047         LDKNodeFeatures this_arg_conv;
37048         this_arg_conv.inner = (void*)(this_arg & (~1));
37049         this_arg_conv.is_owned = false;
37050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37051         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37052 }
37053
37054 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37055         LDKNodeFeatures this_arg_conv;
37056         this_arg_conv.inner = (void*)(this_arg & (~1));
37057         this_arg_conv.is_owned = false;
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37059         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37060 }
37061
37062 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
37063         LDKNodeFeatures this_arg_conv;
37064         this_arg_conv.inner = (void*)(this_arg & (~1));
37065         this_arg_conv.is_owned = false;
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37067         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37068         return ret_conv;
37069 }
37070
37071 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
37072         LDKInitFeatures this_arg_conv;
37073         this_arg_conv.inner = (void*)(this_arg & (~1));
37074         this_arg_conv.is_owned = false;
37075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37076         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37077         return ret_conv;
37078 }
37079
37080 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
37081         LDKNodeFeatures this_arg_conv;
37082         this_arg_conv.inner = (void*)(this_arg & (~1));
37083         this_arg_conv.is_owned = false;
37084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37085         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37086         return ret_conv;
37087 }
37088
37089 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
37090         LDKInitFeatures this_arg_conv;
37091         this_arg_conv.inner = (void*)(this_arg & (~1));
37092         this_arg_conv.is_owned = false;
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37094         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37095 }
37096
37097 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
37098         LDKInitFeatures this_arg_conv;
37099         this_arg_conv.inner = (void*)(this_arg & (~1));
37100         this_arg_conv.is_owned = false;
37101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37102         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37103 }
37104
37105 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
37106         LDKInitFeatures this_arg_conv;
37107         this_arg_conv.inner = (void*)(this_arg & (~1));
37108         this_arg_conv.is_owned = false;
37109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37110         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37111         return ret_conv;
37112 }
37113
37114 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37115         LDKInitFeatures this_arg_conv;
37116         this_arg_conv.inner = (void*)(this_arg & (~1));
37117         this_arg_conv.is_owned = false;
37118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37119         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37120 }
37121
37122 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37123         LDKInitFeatures this_arg_conv;
37124         this_arg_conv.inner = (void*)(this_arg & (~1));
37125         this_arg_conv.is_owned = false;
37126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37127         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37128 }
37129
37130 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37131         LDKInitFeatures this_arg_conv;
37132         this_arg_conv.inner = (void*)(this_arg & (~1));
37133         this_arg_conv.is_owned = false;
37134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37135         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37136         return ret_conv;
37137 }
37138
37139 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37140         LDKNodeFeatures this_arg_conv;
37141         this_arg_conv.inner = (void*)(this_arg & (~1));
37142         this_arg_conv.is_owned = false;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37144         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37145 }
37146
37147 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37148         LDKNodeFeatures this_arg_conv;
37149         this_arg_conv.inner = (void*)(this_arg & (~1));
37150         this_arg_conv.is_owned = false;
37151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37152         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37153 }
37154
37155 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37156         LDKNodeFeatures this_arg_conv;
37157         this_arg_conv.inner = (void*)(this_arg & (~1));
37158         this_arg_conv.is_owned = false;
37159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37160         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37161         return ret_conv;
37162 }
37163
37164 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37165         LDKInitFeatures this_arg_conv;
37166         this_arg_conv.inner = (void*)(this_arg & (~1));
37167         this_arg_conv.is_owned = false;
37168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37169         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37170         return ret_conv;
37171 }
37172
37173 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37174         LDKNodeFeatures this_arg_conv;
37175         this_arg_conv.inner = (void*)(this_arg & (~1));
37176         this_arg_conv.is_owned = false;
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37178         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37179         return ret_conv;
37180 }
37181
37182 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37183         LDKInitFeatures this_arg_conv;
37184         this_arg_conv.inner = (void*)(this_arg & (~1));
37185         this_arg_conv.is_owned = false;
37186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37187         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
37188 }
37189
37190 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
37191         LDKInitFeatures this_arg_conv;
37192         this_arg_conv.inner = (void*)(this_arg & (~1));
37193         this_arg_conv.is_owned = false;
37194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37195         InitFeatures_set_gossip_queries_required(&this_arg_conv);
37196 }
37197
37198 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
37199         LDKInitFeatures this_arg_conv;
37200         this_arg_conv.inner = (void*)(this_arg & (~1));
37201         this_arg_conv.is_owned = false;
37202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37203         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
37204         return ret_conv;
37205 }
37206
37207 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37208         LDKNodeFeatures this_arg_conv;
37209         this_arg_conv.inner = (void*)(this_arg & (~1));
37210         this_arg_conv.is_owned = false;
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37212         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
37213 }
37214
37215 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
37216         LDKNodeFeatures this_arg_conv;
37217         this_arg_conv.inner = (void*)(this_arg & (~1));
37218         this_arg_conv.is_owned = false;
37219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37220         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
37221 }
37222
37223 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
37224         LDKNodeFeatures this_arg_conv;
37225         this_arg_conv.inner = (void*)(this_arg & (~1));
37226         this_arg_conv.is_owned = false;
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37228         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
37229         return ret_conv;
37230 }
37231
37232 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
37233         LDKInitFeatures this_arg_conv;
37234         this_arg_conv.inner = (void*)(this_arg & (~1));
37235         this_arg_conv.is_owned = false;
37236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37237         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
37238         return ret_conv;
37239 }
37240
37241 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
37242         LDKNodeFeatures this_arg_conv;
37243         this_arg_conv.inner = (void*)(this_arg & (~1));
37244         this_arg_conv.is_owned = false;
37245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37246         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
37247         return ret_conv;
37248 }
37249
37250 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37251         LDKInitFeatures this_arg_conv;
37252         this_arg_conv.inner = (void*)(this_arg & (~1));
37253         this_arg_conv.is_owned = false;
37254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37255         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
37256 }
37257
37258 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37259         LDKInitFeatures this_arg_conv;
37260         this_arg_conv.inner = (void*)(this_arg & (~1));
37261         this_arg_conv.is_owned = false;
37262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37263         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
37264 }
37265
37266 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
37267         LDKInitFeatures this_arg_conv;
37268         this_arg_conv.inner = (void*)(this_arg & (~1));
37269         this_arg_conv.is_owned = false;
37270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37271         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
37272         return ret_conv;
37273 }
37274
37275 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37276         LDKNodeFeatures this_arg_conv;
37277         this_arg_conv.inner = (void*)(this_arg & (~1));
37278         this_arg_conv.is_owned = false;
37279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37280         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
37281 }
37282
37283 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37284         LDKNodeFeatures this_arg_conv;
37285         this_arg_conv.inner = (void*)(this_arg & (~1));
37286         this_arg_conv.is_owned = false;
37287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37288         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
37289 }
37290
37291 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
37292         LDKNodeFeatures this_arg_conv;
37293         this_arg_conv.inner = (void*)(this_arg & (~1));
37294         this_arg_conv.is_owned = false;
37295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37296         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
37297         return ret_conv;
37298 }
37299
37300 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37301         LDKInvoiceFeatures this_arg_conv;
37302         this_arg_conv.inner = (void*)(this_arg & (~1));
37303         this_arg_conv.is_owned = false;
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37305         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
37306 }
37307
37308 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37309         LDKInvoiceFeatures this_arg_conv;
37310         this_arg_conv.inner = (void*)(this_arg & (~1));
37311         this_arg_conv.is_owned = false;
37312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37313         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
37314 }
37315
37316 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
37317         LDKInvoiceFeatures this_arg_conv;
37318         this_arg_conv.inner = (void*)(this_arg & (~1));
37319         this_arg_conv.is_owned = false;
37320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37321         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
37322         return ret_conv;
37323 }
37324
37325 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
37326         LDKInitFeatures this_arg_conv;
37327         this_arg_conv.inner = (void*)(this_arg & (~1));
37328         this_arg_conv.is_owned = false;
37329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37330         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
37331         return ret_conv;
37332 }
37333
37334 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
37335         LDKNodeFeatures this_arg_conv;
37336         this_arg_conv.inner = (void*)(this_arg & (~1));
37337         this_arg_conv.is_owned = false;
37338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37339         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
37340         return ret_conv;
37341 }
37342
37343 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
37344         LDKInvoiceFeatures this_arg_conv;
37345         this_arg_conv.inner = (void*)(this_arg & (~1));
37346         this_arg_conv.is_owned = false;
37347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37348         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
37349         return ret_conv;
37350 }
37351
37352 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37353         LDKInitFeatures this_arg_conv;
37354         this_arg_conv.inner = (void*)(this_arg & (~1));
37355         this_arg_conv.is_owned = false;
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37357         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
37358 }
37359
37360 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
37361         LDKInitFeatures this_arg_conv;
37362         this_arg_conv.inner = (void*)(this_arg & (~1));
37363         this_arg_conv.is_owned = false;
37364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37365         InitFeatures_set_static_remote_key_required(&this_arg_conv);
37366 }
37367
37368 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
37369         LDKInitFeatures this_arg_conv;
37370         this_arg_conv.inner = (void*)(this_arg & (~1));
37371         this_arg_conv.is_owned = false;
37372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37373         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
37374         return ret_conv;
37375 }
37376
37377 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37378         LDKNodeFeatures this_arg_conv;
37379         this_arg_conv.inner = (void*)(this_arg & (~1));
37380         this_arg_conv.is_owned = false;
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37382         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
37383 }
37384
37385 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
37386         LDKNodeFeatures this_arg_conv;
37387         this_arg_conv.inner = (void*)(this_arg & (~1));
37388         this_arg_conv.is_owned = false;
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37390         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
37391 }
37392
37393 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
37394         LDKNodeFeatures this_arg_conv;
37395         this_arg_conv.inner = (void*)(this_arg & (~1));
37396         this_arg_conv.is_owned = false;
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37398         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
37399         return ret_conv;
37400 }
37401
37402 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37403         LDKChannelTypeFeatures this_arg_conv;
37404         this_arg_conv.inner = (void*)(this_arg & (~1));
37405         this_arg_conv.is_owned = false;
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37407         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
37408 }
37409
37410 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
37411         LDKChannelTypeFeatures this_arg_conv;
37412         this_arg_conv.inner = (void*)(this_arg & (~1));
37413         this_arg_conv.is_owned = false;
37414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37415         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
37416 }
37417
37418 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
37419         LDKChannelTypeFeatures this_arg_conv;
37420         this_arg_conv.inner = (void*)(this_arg & (~1));
37421         this_arg_conv.is_owned = false;
37422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37423         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
37424         return ret_conv;
37425 }
37426
37427 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
37428         LDKInitFeatures this_arg_conv;
37429         this_arg_conv.inner = (void*)(this_arg & (~1));
37430         this_arg_conv.is_owned = false;
37431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37432         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
37433         return ret_conv;
37434 }
37435
37436 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
37437         LDKNodeFeatures this_arg_conv;
37438         this_arg_conv.inner = (void*)(this_arg & (~1));
37439         this_arg_conv.is_owned = false;
37440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37441         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
37442         return ret_conv;
37443 }
37444
37445 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
37446         LDKChannelTypeFeatures this_arg_conv;
37447         this_arg_conv.inner = (void*)(this_arg & (~1));
37448         this_arg_conv.is_owned = false;
37449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37450         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
37451         return ret_conv;
37452 }
37453
37454 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
37455         LDKInitFeatures this_arg_conv;
37456         this_arg_conv.inner = (void*)(this_arg & (~1));
37457         this_arg_conv.is_owned = false;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37459         InitFeatures_set_payment_secret_optional(&this_arg_conv);
37460 }
37461
37462 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
37463         LDKInitFeatures this_arg_conv;
37464         this_arg_conv.inner = (void*)(this_arg & (~1));
37465         this_arg_conv.is_owned = false;
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37467         InitFeatures_set_payment_secret_required(&this_arg_conv);
37468 }
37469
37470 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
37471         LDKInitFeatures this_arg_conv;
37472         this_arg_conv.inner = (void*)(this_arg & (~1));
37473         this_arg_conv.is_owned = false;
37474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37475         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
37476         return ret_conv;
37477 }
37478
37479 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
37480         LDKNodeFeatures this_arg_conv;
37481         this_arg_conv.inner = (void*)(this_arg & (~1));
37482         this_arg_conv.is_owned = false;
37483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37484         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
37485 }
37486
37487 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
37488         LDKNodeFeatures this_arg_conv;
37489         this_arg_conv.inner = (void*)(this_arg & (~1));
37490         this_arg_conv.is_owned = false;
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37492         NodeFeatures_set_payment_secret_required(&this_arg_conv);
37493 }
37494
37495 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
37496         LDKNodeFeatures this_arg_conv;
37497         this_arg_conv.inner = (void*)(this_arg & (~1));
37498         this_arg_conv.is_owned = false;
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37500         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
37501         return ret_conv;
37502 }
37503
37504 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
37505         LDKInvoiceFeatures this_arg_conv;
37506         this_arg_conv.inner = (void*)(this_arg & (~1));
37507         this_arg_conv.is_owned = false;
37508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37509         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
37510 }
37511
37512 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
37513         LDKInvoiceFeatures this_arg_conv;
37514         this_arg_conv.inner = (void*)(this_arg & (~1));
37515         this_arg_conv.is_owned = false;
37516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37517         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
37518 }
37519
37520 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
37521         LDKInvoiceFeatures this_arg_conv;
37522         this_arg_conv.inner = (void*)(this_arg & (~1));
37523         this_arg_conv.is_owned = false;
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37525         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
37526         return ret_conv;
37527 }
37528
37529 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
37530         LDKInitFeatures this_arg_conv;
37531         this_arg_conv.inner = (void*)(this_arg & (~1));
37532         this_arg_conv.is_owned = false;
37533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37534         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
37535         return ret_conv;
37536 }
37537
37538 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
37539         LDKNodeFeatures this_arg_conv;
37540         this_arg_conv.inner = (void*)(this_arg & (~1));
37541         this_arg_conv.is_owned = false;
37542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37543         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
37544         return ret_conv;
37545 }
37546
37547 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
37548         LDKInvoiceFeatures this_arg_conv;
37549         this_arg_conv.inner = (void*)(this_arg & (~1));
37550         this_arg_conv.is_owned = false;
37551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37552         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
37553         return ret_conv;
37554 }
37555
37556 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37557         LDKInitFeatures this_arg_conv;
37558         this_arg_conv.inner = (void*)(this_arg & (~1));
37559         this_arg_conv.is_owned = false;
37560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37561         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
37562 }
37563
37564 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
37565         LDKInitFeatures this_arg_conv;
37566         this_arg_conv.inner = (void*)(this_arg & (~1));
37567         this_arg_conv.is_owned = false;
37568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37569         InitFeatures_set_basic_mpp_required(&this_arg_conv);
37570 }
37571
37572 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
37573         LDKInitFeatures this_arg_conv;
37574         this_arg_conv.inner = (void*)(this_arg & (~1));
37575         this_arg_conv.is_owned = false;
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37577         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
37578         return ret_conv;
37579 }
37580
37581 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37582         LDKNodeFeatures this_arg_conv;
37583         this_arg_conv.inner = (void*)(this_arg & (~1));
37584         this_arg_conv.is_owned = false;
37585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37586         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
37587 }
37588
37589 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
37590         LDKNodeFeatures this_arg_conv;
37591         this_arg_conv.inner = (void*)(this_arg & (~1));
37592         this_arg_conv.is_owned = false;
37593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37594         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
37595 }
37596
37597 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
37598         LDKNodeFeatures this_arg_conv;
37599         this_arg_conv.inner = (void*)(this_arg & (~1));
37600         this_arg_conv.is_owned = false;
37601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37602         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
37603         return ret_conv;
37604 }
37605
37606 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37607         LDKInvoiceFeatures this_arg_conv;
37608         this_arg_conv.inner = (void*)(this_arg & (~1));
37609         this_arg_conv.is_owned = false;
37610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37611         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
37612 }
37613
37614 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
37615         LDKInvoiceFeatures this_arg_conv;
37616         this_arg_conv.inner = (void*)(this_arg & (~1));
37617         this_arg_conv.is_owned = false;
37618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37619         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
37620 }
37621
37622 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
37623         LDKInvoiceFeatures this_arg_conv;
37624         this_arg_conv.inner = (void*)(this_arg & (~1));
37625         this_arg_conv.is_owned = false;
37626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37627         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
37628         return ret_conv;
37629 }
37630
37631 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
37632         LDKInitFeatures this_arg_conv;
37633         this_arg_conv.inner = (void*)(this_arg & (~1));
37634         this_arg_conv.is_owned = false;
37635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37636         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
37637         return ret_conv;
37638 }
37639
37640 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
37641         LDKNodeFeatures this_arg_conv;
37642         this_arg_conv.inner = (void*)(this_arg & (~1));
37643         this_arg_conv.is_owned = false;
37644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37645         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
37646         return ret_conv;
37647 }
37648
37649 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
37650         LDKInvoiceFeatures this_arg_conv;
37651         this_arg_conv.inner = (void*)(this_arg & (~1));
37652         this_arg_conv.is_owned = false;
37653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37654         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
37655         return ret_conv;
37656 }
37657
37658 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
37659         LDKInitFeatures this_arg_conv;
37660         this_arg_conv.inner = (void*)(this_arg & (~1));
37661         this_arg_conv.is_owned = false;
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37663         InitFeatures_set_wumbo_optional(&this_arg_conv);
37664 }
37665
37666 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
37667         LDKInitFeatures this_arg_conv;
37668         this_arg_conv.inner = (void*)(this_arg & (~1));
37669         this_arg_conv.is_owned = false;
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37671         InitFeatures_set_wumbo_required(&this_arg_conv);
37672 }
37673
37674 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
37675         LDKInitFeatures this_arg_conv;
37676         this_arg_conv.inner = (void*)(this_arg & (~1));
37677         this_arg_conv.is_owned = false;
37678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37679         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
37680         return ret_conv;
37681 }
37682
37683 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
37684         LDKNodeFeatures this_arg_conv;
37685         this_arg_conv.inner = (void*)(this_arg & (~1));
37686         this_arg_conv.is_owned = false;
37687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37688         NodeFeatures_set_wumbo_optional(&this_arg_conv);
37689 }
37690
37691 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
37692         LDKNodeFeatures this_arg_conv;
37693         this_arg_conv.inner = (void*)(this_arg & (~1));
37694         this_arg_conv.is_owned = false;
37695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37696         NodeFeatures_set_wumbo_required(&this_arg_conv);
37697 }
37698
37699 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
37700         LDKNodeFeatures this_arg_conv;
37701         this_arg_conv.inner = (void*)(this_arg & (~1));
37702         this_arg_conv.is_owned = false;
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37704         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
37705         return ret_conv;
37706 }
37707
37708 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
37709         LDKInitFeatures this_arg_conv;
37710         this_arg_conv.inner = (void*)(this_arg & (~1));
37711         this_arg_conv.is_owned = false;
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37713         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
37714         return ret_conv;
37715 }
37716
37717 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
37718         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
37723         return ret_conv;
37724 }
37725
37726 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37727         LDKInitFeatures this_arg_conv;
37728         this_arg_conv.inner = (void*)(this_arg & (~1));
37729         this_arg_conv.is_owned = false;
37730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37731         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37732 }
37733
37734 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37735         LDKInitFeatures this_arg_conv;
37736         this_arg_conv.inner = (void*)(this_arg & (~1));
37737         this_arg_conv.is_owned = false;
37738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37739         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37740 }
37741
37742 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37743         LDKInitFeatures 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         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37748         return ret_conv;
37749 }
37750
37751 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37752         LDKNodeFeatures this_arg_conv;
37753         this_arg_conv.inner = (void*)(this_arg & (~1));
37754         this_arg_conv.is_owned = false;
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37756         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37757 }
37758
37759 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37760         LDKNodeFeatures this_arg_conv;
37761         this_arg_conv.inner = (void*)(this_arg & (~1));
37762         this_arg_conv.is_owned = false;
37763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37764         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37765 }
37766
37767 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37768         LDKNodeFeatures 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 = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37773         return ret_conv;
37774 }
37775
37776 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37777         LDKInitFeatures 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 = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37782         return ret_conv;
37783 }
37784
37785 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37786         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37791         return ret_conv;
37792 }
37793
37794 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
37795         LDKInitFeatures this_arg_conv;
37796         this_arg_conv.inner = (void*)(this_arg & (~1));
37797         this_arg_conv.is_owned = false;
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37799         InitFeatures_set_channel_type_optional(&this_arg_conv);
37800 }
37801
37802 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
37803         LDKInitFeatures this_arg_conv;
37804         this_arg_conv.inner = (void*)(this_arg & (~1));
37805         this_arg_conv.is_owned = false;
37806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37807         InitFeatures_set_channel_type_required(&this_arg_conv);
37808 }
37809
37810 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(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         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
37816         return ret_conv;
37817 }
37818
37819 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
37820         LDKNodeFeatures this_arg_conv;
37821         this_arg_conv.inner = (void*)(this_arg & (~1));
37822         this_arg_conv.is_owned = false;
37823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37824         NodeFeatures_set_channel_type_optional(&this_arg_conv);
37825 }
37826
37827 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
37828         LDKNodeFeatures this_arg_conv;
37829         this_arg_conv.inner = (void*)(this_arg & (~1));
37830         this_arg_conv.is_owned = false;
37831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37832         NodeFeatures_set_channel_type_required(&this_arg_conv);
37833 }
37834
37835 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(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         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
37841         return ret_conv;
37842 }
37843
37844 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
37845         LDKInitFeatures this_arg_conv;
37846         this_arg_conv.inner = (void*)(this_arg & (~1));
37847         this_arg_conv.is_owned = false;
37848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37849         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
37850         return ret_conv;
37851 }
37852
37853 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
37854         LDKNodeFeatures this_arg_conv;
37855         this_arg_conv.inner = (void*)(this_arg & (~1));
37856         this_arg_conv.is_owned = false;
37857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37858         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
37859         return ret_conv;
37860 }
37861
37862 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37863         LDKInitFeatures this_arg_conv;
37864         this_arg_conv.inner = (void*)(this_arg & (~1));
37865         this_arg_conv.is_owned = false;
37866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37867         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
37868 }
37869
37870 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
37871         LDKInitFeatures this_arg_conv;
37872         this_arg_conv.inner = (void*)(this_arg & (~1));
37873         this_arg_conv.is_owned = false;
37874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37875         InitFeatures_set_scid_privacy_required(&this_arg_conv);
37876 }
37877
37878 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(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         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
37884         return ret_conv;
37885 }
37886
37887 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37888         LDKNodeFeatures this_arg_conv;
37889         this_arg_conv.inner = (void*)(this_arg & (~1));
37890         this_arg_conv.is_owned = false;
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37892         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
37893 }
37894
37895 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37896         LDKNodeFeatures this_arg_conv;
37897         this_arg_conv.inner = (void*)(this_arg & (~1));
37898         this_arg_conv.is_owned = false;
37899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37900         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
37901 }
37902
37903 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(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         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
37909         return ret_conv;
37910 }
37911
37912 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37913         LDKChannelTypeFeatures this_arg_conv;
37914         this_arg_conv.inner = (void*)(this_arg & (~1));
37915         this_arg_conv.is_owned = false;
37916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37917         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
37918 }
37919
37920 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37921         LDKChannelTypeFeatures this_arg_conv;
37922         this_arg_conv.inner = (void*)(this_arg & (~1));
37923         this_arg_conv.is_owned = false;
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37925         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
37926 }
37927
37928 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
37929         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
37934         return ret_conv;
37935 }
37936
37937 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
37938         LDKInitFeatures 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 = InitFeatures_requires_scid_privacy(&this_arg_conv);
37943         return ret_conv;
37944 }
37945
37946 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
37947         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
37952         return ret_conv;
37953 }
37954
37955 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
37956         LDKChannelTypeFeatures this_arg_conv;
37957         this_arg_conv.inner = (void*)(this_arg & (~1));
37958         this_arg_conv.is_owned = false;
37959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37960         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
37961         return ret_conv;
37962 }
37963
37964 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
37965         LDKInitFeatures this_arg_conv;
37966         this_arg_conv.inner = (void*)(this_arg & (~1));
37967         this_arg_conv.is_owned = false;
37968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37969         InitFeatures_set_zero_conf_optional(&this_arg_conv);
37970 }
37971
37972 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
37973         LDKInitFeatures this_arg_conv;
37974         this_arg_conv.inner = (void*)(this_arg & (~1));
37975         this_arg_conv.is_owned = false;
37976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37977         InitFeatures_set_zero_conf_required(&this_arg_conv);
37978 }
37979
37980 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
37981         LDKInitFeatures this_arg_conv;
37982         this_arg_conv.inner = (void*)(this_arg & (~1));
37983         this_arg_conv.is_owned = false;
37984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37985         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
37986         return ret_conv;
37987 }
37988
37989 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
37990         LDKNodeFeatures this_arg_conv;
37991         this_arg_conv.inner = (void*)(this_arg & (~1));
37992         this_arg_conv.is_owned = false;
37993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37994         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
37995 }
37996
37997 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
37998         LDKNodeFeatures this_arg_conv;
37999         this_arg_conv.inner = (void*)(this_arg & (~1));
38000         this_arg_conv.is_owned = false;
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38002         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38003 }
38004
38005 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
38006         LDKNodeFeatures this_arg_conv;
38007         this_arg_conv.inner = (void*)(this_arg & (~1));
38008         this_arg_conv.is_owned = false;
38009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38010         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38011         return ret_conv;
38012 }
38013
38014 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38015         LDKChannelTypeFeatures this_arg_conv;
38016         this_arg_conv.inner = (void*)(this_arg & (~1));
38017         this_arg_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38019         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38020 }
38021
38022 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
38023         LDKChannelTypeFeatures this_arg_conv;
38024         this_arg_conv.inner = (void*)(this_arg & (~1));
38025         this_arg_conv.is_owned = false;
38026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38027         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38028 }
38029
38030 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
38031         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
38036         return ret_conv;
38037 }
38038
38039 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint32_t this_arg) {
38040         LDKInitFeatures 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 = InitFeatures_requires_zero_conf(&this_arg_conv);
38045         return ret_conv;
38046 }
38047
38048 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
38049         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38054         return ret_conv;
38055 }
38056
38057 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
38058         LDKChannelTypeFeatures this_arg_conv;
38059         this_arg_conv.inner = (void*)(this_arg & (~1));
38060         this_arg_conv.is_owned = false;
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38062         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38063         return ret_conv;
38064 }
38065
38066 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
38067         LDKNodeFeatures this_arg_conv;
38068         this_arg_conv.inner = (void*)(this_arg & (~1));
38069         this_arg_conv.is_owned = false;
38070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38071         NodeFeatures_set_keysend_optional(&this_arg_conv);
38072 }
38073
38074 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
38075         LDKNodeFeatures this_arg_conv;
38076         this_arg_conv.inner = (void*)(this_arg & (~1));
38077         this_arg_conv.is_owned = false;
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38079         NodeFeatures_set_keysend_required(&this_arg_conv);
38080 }
38081
38082 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
38083         LDKNodeFeatures this_arg_conv;
38084         this_arg_conv.inner = (void*)(this_arg & (~1));
38085         this_arg_conv.is_owned = false;
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38087         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38088         return ret_conv;
38089 }
38090
38091 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
38092         LDKNodeFeatures this_arg_conv;
38093         this_arg_conv.inner = (void*)(this_arg & (~1));
38094         this_arg_conv.is_owned = false;
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38096         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38097         return ret_conv;
38098 }
38099
38100 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
38101         LDKShutdownScript this_obj_conv;
38102         this_obj_conv.inner = (void*)(this_obj & (~1));
38103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38105         ShutdownScript_free(this_obj_conv);
38106 }
38107
38108 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38109         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38110 uint32_t ret_ref = 0;
38111 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38112 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38113 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38114 ret_ref = (uintptr_t)ret_var.inner;
38115 if (ret_var.is_owned) {
38116         ret_ref |= 1;
38117 }
38118         return ret_ref;
38119 }
38120 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
38121         LDKShutdownScript arg_conv;
38122         arg_conv.inner = (void*)(arg & (~1));
38123         arg_conv.is_owned = false;
38124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38125         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38126         return ret_conv;
38127 }
38128
38129 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
38130         LDKShutdownScript orig_conv;
38131         orig_conv.inner = (void*)(orig & (~1));
38132         orig_conv.is_owned = false;
38133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38134         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38135         uint32_t ret_ref = 0;
38136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38139         ret_ref = (uintptr_t)ret_var.inner;
38140         if (ret_var.is_owned) {
38141                 ret_ref |= 1;
38142         }
38143         return ret_ref;
38144 }
38145
38146 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
38147         LDKInvalidShutdownScript this_obj_conv;
38148         this_obj_conv.inner = (void*)(this_obj & (~1));
38149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38151         InvalidShutdownScript_free(this_obj_conv);
38152 }
38153
38154 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
38155         LDKInvalidShutdownScript this_ptr_conv;
38156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38157         this_ptr_conv.is_owned = false;
38158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38159         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38162         return ret_arr;
38163 }
38164
38165 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
38166         LDKInvalidShutdownScript this_ptr_conv;
38167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38168         this_ptr_conv.is_owned = false;
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38170         LDKCVec_u8Z val_ref;
38171         val_ref.datalen = val->arr_len;
38172         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38173         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38174         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38175 }
38176
38177 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
38178         LDKCVec_u8Z script_arg_ref;
38179         script_arg_ref.datalen = script_arg->arr_len;
38180         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38181         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
38182         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
38183         uint32_t ret_ref = 0;
38184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38187         ret_ref = (uintptr_t)ret_var.inner;
38188         if (ret_var.is_owned) {
38189                 ret_ref |= 1;
38190         }
38191         return ret_ref;
38192 }
38193
38194 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
38195         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
38196 uint32_t ret_ref = 0;
38197 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38198 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38199 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38200 ret_ref = (uintptr_t)ret_var.inner;
38201 if (ret_var.is_owned) {
38202         ret_ref |= 1;
38203 }
38204         return ret_ref;
38205 }
38206 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
38207         LDKInvalidShutdownScript arg_conv;
38208         arg_conv.inner = (void*)(arg & (~1));
38209         arg_conv.is_owned = false;
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38211         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
38212         return ret_conv;
38213 }
38214
38215 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
38216         LDKInvalidShutdownScript orig_conv;
38217         orig_conv.inner = (void*)(orig & (~1));
38218         orig_conv.is_owned = false;
38219         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38220         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
38221         uint32_t ret_ref = 0;
38222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38225         ret_ref = (uintptr_t)ret_var.inner;
38226         if (ret_var.is_owned) {
38227                 ret_ref |= 1;
38228         }
38229         return ret_ref;
38230 }
38231
38232 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
38233         LDKShutdownScript obj_conv;
38234         obj_conv.inner = (void*)(obj & (~1));
38235         obj_conv.is_owned = false;
38236         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38237         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
38238         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38239         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38240         CVec_u8Z_free(ret_var);
38241         return ret_arr;
38242 }
38243
38244 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
38245         LDKu8slice ser_ref;
38246         ser_ref.datalen = ser->arr_len;
38247         ser_ref.data = ser->elems;
38248         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
38249         *ret_conv = ShutdownScript_read(ser_ref);
38250         FREE(ser);
38251         return (uint32_t)ret_conv;
38252 }
38253
38254 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
38255         unsigned char pubkey_hash_arr[20];
38256         CHECK(pubkey_hash->arr_len == 20);
38257         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
38258         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
38259         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
38260         uint32_t ret_ref = 0;
38261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38264         ret_ref = (uintptr_t)ret_var.inner;
38265         if (ret_var.is_owned) {
38266                 ret_ref |= 1;
38267         }
38268         return ret_ref;
38269 }
38270
38271 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
38272         unsigned char script_hash_arr[32];
38273         CHECK(script_hash->arr_len == 32);
38274         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
38275         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
38276         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
38277         uint32_t ret_ref = 0;
38278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38281         ret_ref = (uintptr_t)ret_var.inner;
38282         if (ret_var.is_owned) {
38283                 ret_ref |= 1;
38284         }
38285         return ret_ref;
38286 }
38287
38288 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
38289         
38290         LDKu8slice program_ref;
38291         program_ref.datalen = program->arr_len;
38292         program_ref.data = program->elems;
38293         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
38294         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
38295         FREE(program);
38296         return (uint32_t)ret_conv;
38297 }
38298
38299 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
38300         LDKShutdownScript this_arg_conv;
38301         this_arg_conv.inner = (void*)(this_arg & (~1));
38302         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38304         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
38305         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
38306         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38307         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38308         CVec_u8Z_free(ret_var);
38309         return ret_arr;
38310 }
38311
38312 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
38313         LDKShutdownScript this_arg_conv;
38314         this_arg_conv.inner = (void*)(this_arg & (~1));
38315         this_arg_conv.is_owned = false;
38316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38317         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38318         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
38319         return ret_arr;
38320 }
38321
38322 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
38323         LDKShutdownScript this_arg_conv;
38324         this_arg_conv.inner = (void*)(this_arg & (~1));
38325         this_arg_conv.is_owned = false;
38326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38327         LDKInitFeatures features_conv;
38328         features_conv.inner = (void*)(features & (~1));
38329         features_conv.is_owned = false;
38330         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
38331         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
38332         return ret_conv;
38333 }
38334
38335 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
38336         if ((this_ptr & 1) != 0) return;
38337         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38338         CHECK_ACCESS(this_ptr_ptr);
38339         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
38340         FREE((void*)this_ptr);
38341         CustomMessageReader_free(this_ptr_conv);
38342 }
38343
38344 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
38345         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38346         *ret_ret = Type_clone(arg);
38347         return (uint32_t)ret_ret;
38348 }
38349 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
38350         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38351         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38352         LDKType* arg_conv = (LDKType*)arg_ptr;
38353         uint32_t ret_conv = Type_clone_ptr(arg_conv);
38354         return ret_conv;
38355 }
38356
38357 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
38358         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38359         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38360         LDKType* orig_conv = (LDKType*)orig_ptr;
38361         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38362         *ret_ret = Type_clone(orig_conv);
38363         return (uint32_t)ret_ret;
38364 }
38365
38366 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
38367         if ((this_ptr & 1) != 0) return;
38368         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38369         CHECK_ACCESS(this_ptr_ptr);
38370         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
38371         FREE((void*)this_ptr);
38372         Type_free(this_ptr_conv);
38373 }
38374
38375 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
38376         LDKNodeId this_obj_conv;
38377         this_obj_conv.inner = (void*)(this_obj & (~1));
38378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38380         NodeId_free(this_obj_conv);
38381 }
38382
38383 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
38384         LDKNodeId ret_var = NodeId_clone(arg);
38385 uint32_t ret_ref = 0;
38386 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38387 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38388 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38389 ret_ref = (uintptr_t)ret_var.inner;
38390 if (ret_var.is_owned) {
38391         ret_ref |= 1;
38392 }
38393         return ret_ref;
38394 }
38395 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
38396         LDKNodeId arg_conv;
38397         arg_conv.inner = (void*)(arg & (~1));
38398         arg_conv.is_owned = false;
38399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38400         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
38401         return ret_conv;
38402 }
38403
38404 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
38405         LDKNodeId orig_conv;
38406         orig_conv.inner = (void*)(orig & (~1));
38407         orig_conv.is_owned = false;
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38409         LDKNodeId ret_var = NodeId_clone(&orig_conv);
38410         uint32_t ret_ref = 0;
38411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38414         ret_ref = (uintptr_t)ret_var.inner;
38415         if (ret_var.is_owned) {
38416                 ret_ref |= 1;
38417         }
38418         return ret_ref;
38419 }
38420
38421 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
38422         LDKPublicKey pubkey_ref;
38423         CHECK(pubkey->arr_len == 33);
38424         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
38425         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
38426         uint32_t ret_ref = 0;
38427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38430         ret_ref = (uintptr_t)ret_var.inner;
38431         if (ret_var.is_owned) {
38432                 ret_ref |= 1;
38433         }
38434         return ret_ref;
38435 }
38436
38437 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
38438         LDKNodeId this_arg_conv;
38439         this_arg_conv.inner = (void*)(this_arg & (~1));
38440         this_arg_conv.is_owned = false;
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38442         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
38443         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38444         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38445         return ret_arr;
38446 }
38447
38448 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
38449         LDKNodeId o_conv;
38450         o_conv.inner = (void*)(o & (~1));
38451         o_conv.is_owned = false;
38452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38453         int64_t ret_conv = NodeId_hash(&o_conv);
38454         return ret_conv;
38455 }
38456
38457 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
38458         LDKNodeId obj_conv;
38459         obj_conv.inner = (void*)(obj & (~1));
38460         obj_conv.is_owned = false;
38461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38462         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
38463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38465         CVec_u8Z_free(ret_var);
38466         return ret_arr;
38467 }
38468
38469 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
38470         LDKu8slice ser_ref;
38471         ser_ref.datalen = ser->arr_len;
38472         ser_ref.data = ser->elems;
38473         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
38474         *ret_conv = NodeId_read(ser_ref);
38475         FREE(ser);
38476         return (uint32_t)ret_conv;
38477 }
38478
38479 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
38480         LDKNetworkGraph this_obj_conv;
38481         this_obj_conv.inner = (void*)(this_obj & (~1));
38482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38484         NetworkGraph_free(this_obj_conv);
38485 }
38486
38487 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
38488         LDKReadOnlyNetworkGraph this_obj_conv;
38489         this_obj_conv.inner = (void*)(this_obj & (~1));
38490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38492         ReadOnlyNetworkGraph_free(this_obj_conv);
38493 }
38494
38495 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
38496         if ((this_ptr & 1) != 0) return;
38497         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38498         CHECK_ACCESS(this_ptr_ptr);
38499         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
38500         FREE((void*)this_ptr);
38501         NetworkUpdate_free(this_ptr_conv);
38502 }
38503
38504 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
38505         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38506         *ret_copy = NetworkUpdate_clone(arg);
38507 uint32_t ret_ref = (uintptr_t)ret_copy;
38508         return ret_ref;
38509 }
38510 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
38511         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
38512         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
38513         return ret_conv;
38514 }
38515
38516 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
38517         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
38518         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38519         *ret_copy = NetworkUpdate_clone(orig_conv);
38520         uint32_t ret_ref = (uintptr_t)ret_copy;
38521         return ret_ref;
38522 }
38523
38524 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
38525         LDKChannelUpdate msg_conv;
38526         msg_conv.inner = (void*)(msg & (~1));
38527         msg_conv.is_owned = (msg & 1) || (msg == 0);
38528         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38529         msg_conv = ChannelUpdate_clone(&msg_conv);
38530         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38531         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
38532         uint32_t ret_ref = (uintptr_t)ret_copy;
38533         return ret_ref;
38534 }
38535
38536 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
38537         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38538         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
38539         uint32_t ret_ref = (uintptr_t)ret_copy;
38540         return ret_ref;
38541 }
38542
38543 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
38544         LDKPublicKey node_id_ref;
38545         CHECK(node_id->arr_len == 33);
38546         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
38547         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38548         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
38549         uint32_t ret_ref = (uintptr_t)ret_copy;
38550         return ret_ref;
38551 }
38552
38553 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
38554         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
38555         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
38556         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38557         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38558         CVec_u8Z_free(ret_var);
38559         return ret_arr;
38560 }
38561
38562 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
38563         LDKu8slice ser_ref;
38564         ser_ref.datalen = ser->arr_len;
38565         ser_ref.data = ser->elems;
38566         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
38567         *ret_conv = NetworkUpdate_read(ser_ref);
38568         FREE(ser);
38569         return (uint32_t)ret_conv;
38570 }
38571
38572 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
38573         LDKP2PGossipSync this_obj_conv;
38574         this_obj_conv.inner = (void*)(this_obj & (~1));
38575         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38577         P2PGossipSync_free(this_obj_conv);
38578 }
38579
38580 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
38581         LDKNetworkGraph network_graph_conv;
38582         network_graph_conv.inner = (void*)(network_graph & (~1));
38583         network_graph_conv.is_owned = false;
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
38585         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38586         CHECK_ACCESS(chain_access_ptr);
38587         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38588         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38589         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38590                 // Manually implement clone for Java trait instances
38591                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38592                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38593                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38594                 }
38595         }
38596         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38597         CHECK_ACCESS(logger_ptr);
38598         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38599         if (logger_conv.free == LDKLogger_JCalls_free) {
38600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38601                 LDKLogger_JCalls_cloned(&logger_conv);
38602         }
38603         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
38604         uint32_t ret_ref = 0;
38605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38608         ret_ref = (uintptr_t)ret_var.inner;
38609         if (ret_var.is_owned) {
38610                 ret_ref |= 1;
38611         }
38612         return ret_ref;
38613 }
38614
38615 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
38616         LDKP2PGossipSync this_arg_conv;
38617         this_arg_conv.inner = (void*)(this_arg & (~1));
38618         this_arg_conv.is_owned = false;
38619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38620         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38621         CHECK_ACCESS(chain_access_ptr);
38622         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38623         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38624         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38625                 // Manually implement clone for Java trait instances
38626                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38627                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38628                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38629                 }
38630         }
38631         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
38632 }
38633
38634 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
38635         LDKNetworkGraph this_arg_conv;
38636         this_arg_conv.inner = (void*)(this_arg & (~1));
38637         this_arg_conv.is_owned = false;
38638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38639         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
38640         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
38641         return (uint32_t)ret_ret;
38642 }
38643
38644 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
38645         LDKP2PGossipSync this_arg_conv;
38646         this_arg_conv.inner = (void*)(this_arg & (~1));
38647         this_arg_conv.is_owned = false;
38648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38649         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38650         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
38651         return (uint32_t)ret_ret;
38652 }
38653
38654 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
38655         LDKP2PGossipSync this_arg_conv;
38656         this_arg_conv.inner = (void*)(this_arg & (~1));
38657         this_arg_conv.is_owned = false;
38658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38659         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38660         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
38661         return (uint32_t)ret_ret;
38662 }
38663
38664 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
38665         LDKChannelUpdateInfo this_obj_conv;
38666         this_obj_conv.inner = (void*)(this_obj & (~1));
38667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38669         ChannelUpdateInfo_free(this_obj_conv);
38670 }
38671
38672 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
38673         LDKChannelUpdateInfo this_ptr_conv;
38674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38675         this_ptr_conv.is_owned = false;
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38677         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
38678         return ret_conv;
38679 }
38680
38681 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
38682         LDKChannelUpdateInfo this_ptr_conv;
38683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38684         this_ptr_conv.is_owned = false;
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38686         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
38687 }
38688
38689 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
38690         LDKChannelUpdateInfo this_ptr_conv;
38691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38692         this_ptr_conv.is_owned = false;
38693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38694         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
38695         return ret_conv;
38696 }
38697
38698 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
38699         LDKChannelUpdateInfo this_ptr_conv;
38700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38701         this_ptr_conv.is_owned = false;
38702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38703         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
38704 }
38705
38706 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
38707         LDKChannelUpdateInfo this_ptr_conv;
38708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38709         this_ptr_conv.is_owned = false;
38710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38711         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
38712         return ret_conv;
38713 }
38714
38715 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38716         LDKChannelUpdateInfo this_ptr_conv;
38717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38718         this_ptr_conv.is_owned = false;
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38720         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
38721 }
38722
38723 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
38724         LDKChannelUpdateInfo this_ptr_conv;
38725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38726         this_ptr_conv.is_owned = false;
38727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38728         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
38729         return ret_conv;
38730 }
38731
38732 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
38733         LDKChannelUpdateInfo this_ptr_conv;
38734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38735         this_ptr_conv.is_owned = false;
38736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38737         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
38738 }
38739
38740 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
38741         LDKChannelUpdateInfo this_ptr_conv;
38742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38743         this_ptr_conv.is_owned = false;
38744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38745         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38746         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
38747         uint32_t ret_ref = (uintptr_t)ret_copy;
38748         return ret_ref;
38749 }
38750
38751 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38752         LDKChannelUpdateInfo this_ptr_conv;
38753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38754         this_ptr_conv.is_owned = false;
38755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38756         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38757         CHECK_ACCESS(val_ptr);
38758         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38759         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38760         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38761 }
38762
38763 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
38764         LDKChannelUpdateInfo this_ptr_conv;
38765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38766         this_ptr_conv.is_owned = false;
38767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38768         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
38769         uint32_t ret_ref = 0;
38770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38773         ret_ref = (uintptr_t)ret_var.inner;
38774         if (ret_var.is_owned) {
38775                 ret_ref |= 1;
38776         }
38777         return ret_ref;
38778 }
38779
38780 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
38781         LDKChannelUpdateInfo this_ptr_conv;
38782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38783         this_ptr_conv.is_owned = false;
38784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38785         LDKRoutingFees val_conv;
38786         val_conv.inner = (void*)(val & (~1));
38787         val_conv.is_owned = (val & 1) || (val == 0);
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38789         val_conv = RoutingFees_clone(&val_conv);
38790         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
38791 }
38792
38793 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
38794         LDKChannelUpdateInfo this_ptr_conv;
38795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38796         this_ptr_conv.is_owned = false;
38797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38798         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
38799         uint32_t ret_ref = 0;
38800         if ((uintptr_t)ret_var.inner > 4096) {
38801                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38802                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38804                 ret_ref = (uintptr_t)ret_var.inner;
38805                 if (ret_var.is_owned) {
38806                         ret_ref |= 1;
38807                 }
38808         }
38809         return ret_ref;
38810 }
38811
38812 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
38813         LDKChannelUpdateInfo this_ptr_conv;
38814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38815         this_ptr_conv.is_owned = false;
38816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38817         LDKChannelUpdate val_conv;
38818         val_conv.inner = (void*)(val & (~1));
38819         val_conv.is_owned = (val & 1) || (val == 0);
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38821         val_conv = ChannelUpdate_clone(&val_conv);
38822         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
38823 }
38824
38825 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_new"))) TS_ChannelUpdateInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
38826         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38827         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38828         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38829         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38830         LDKRoutingFees fees_arg_conv;
38831         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38832         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38833         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38834         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38835         LDKChannelUpdate last_update_message_arg_conv;
38836         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
38837         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
38838         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
38839         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
38840         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
38841         uint32_t ret_ref = 0;
38842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38845         ret_ref = (uintptr_t)ret_var.inner;
38846         if (ret_var.is_owned) {
38847                 ret_ref |= 1;
38848         }
38849         return ret_ref;
38850 }
38851
38852 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
38853         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
38854 uint32_t ret_ref = 0;
38855 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38856 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38857 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38858 ret_ref = (uintptr_t)ret_var.inner;
38859 if (ret_var.is_owned) {
38860         ret_ref |= 1;
38861 }
38862         return ret_ref;
38863 }
38864 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
38865         LDKChannelUpdateInfo arg_conv;
38866         arg_conv.inner = (void*)(arg & (~1));
38867         arg_conv.is_owned = false;
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38869         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
38870         return ret_conv;
38871 }
38872
38873 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
38874         LDKChannelUpdateInfo orig_conv;
38875         orig_conv.inner = (void*)(orig & (~1));
38876         orig_conv.is_owned = false;
38877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38878         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
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 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
38891         LDKChannelUpdateInfo obj_conv;
38892         obj_conv.inner = (void*)(obj & (~1));
38893         obj_conv.is_owned = false;
38894         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38895         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
38896         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38897         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38898         CVec_u8Z_free(ret_var);
38899         return ret_arr;
38900 }
38901
38902 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
38903         LDKu8slice ser_ref;
38904         ser_ref.datalen = ser->arr_len;
38905         ser_ref.data = ser->elems;
38906         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
38907         *ret_conv = ChannelUpdateInfo_read(ser_ref);
38908         FREE(ser);
38909         return (uint32_t)ret_conv;
38910 }
38911
38912 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
38913         LDKChannelInfo this_obj_conv;
38914         this_obj_conv.inner = (void*)(this_obj & (~1));
38915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38917         ChannelInfo_free(this_obj_conv);
38918 }
38919
38920 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
38921         LDKChannelInfo this_ptr_conv;
38922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38923         this_ptr_conv.is_owned = false;
38924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38925         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
38926         uint32_t ret_ref = 0;
38927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38930         ret_ref = (uintptr_t)ret_var.inner;
38931         if (ret_var.is_owned) {
38932                 ret_ref |= 1;
38933         }
38934         return ret_ref;
38935 }
38936
38937 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
38938         LDKChannelInfo this_ptr_conv;
38939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38940         this_ptr_conv.is_owned = false;
38941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38942         LDKChannelFeatures val_conv;
38943         val_conv.inner = (void*)(val & (~1));
38944         val_conv.is_owned = (val & 1) || (val == 0);
38945         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38946         val_conv = ChannelFeatures_clone(&val_conv);
38947         ChannelInfo_set_features(&this_ptr_conv, val_conv);
38948 }
38949
38950 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
38951         LDKChannelInfo this_ptr_conv;
38952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38953         this_ptr_conv.is_owned = false;
38954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38955         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
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 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
38968         LDKChannelInfo this_ptr_conv;
38969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38970         this_ptr_conv.is_owned = false;
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38972         LDKNodeId val_conv;
38973         val_conv.inner = (void*)(val & (~1));
38974         val_conv.is_owned = (val & 1) || (val == 0);
38975         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38976         val_conv = NodeId_clone(&val_conv);
38977         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
38978 }
38979
38980 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
38981         LDKChannelInfo this_ptr_conv;
38982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38983         this_ptr_conv.is_owned = false;
38984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38985         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
38986         uint32_t ret_ref = 0;
38987         if ((uintptr_t)ret_var.inner > 4096) {
38988                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38989                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38991                 ret_ref = (uintptr_t)ret_var.inner;
38992                 if (ret_var.is_owned) {
38993                         ret_ref |= 1;
38994                 }
38995         }
38996         return ret_ref;
38997 }
38998
38999 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
39000         LDKChannelInfo this_ptr_conv;
39001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39002         this_ptr_conv.is_owned = false;
39003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39004         LDKChannelUpdateInfo val_conv;
39005         val_conv.inner = (void*)(val & (~1));
39006         val_conv.is_owned = (val & 1) || (val == 0);
39007         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39008         val_conv = ChannelUpdateInfo_clone(&val_conv);
39009         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39010 }
39011
39012 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
39013         LDKChannelInfo this_ptr_conv;
39014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39015         this_ptr_conv.is_owned = false;
39016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39017         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39018         uint32_t ret_ref = 0;
39019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39022         ret_ref = (uintptr_t)ret_var.inner;
39023         if (ret_var.is_owned) {
39024                 ret_ref |= 1;
39025         }
39026         return ret_ref;
39027 }
39028
39029 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
39030         LDKChannelInfo this_ptr_conv;
39031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39032         this_ptr_conv.is_owned = false;
39033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39034         LDKNodeId val_conv;
39035         val_conv.inner = (void*)(val & (~1));
39036         val_conv.is_owned = (val & 1) || (val == 0);
39037         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39038         val_conv = NodeId_clone(&val_conv);
39039         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39040 }
39041
39042 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
39043         LDKChannelInfo this_ptr_conv;
39044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39045         this_ptr_conv.is_owned = false;
39046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39047         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39048         uint32_t ret_ref = 0;
39049         if ((uintptr_t)ret_var.inner > 4096) {
39050                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39051                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39053                 ret_ref = (uintptr_t)ret_var.inner;
39054                 if (ret_var.is_owned) {
39055                         ret_ref |= 1;
39056                 }
39057         }
39058         return ret_ref;
39059 }
39060
39061 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
39062         LDKChannelInfo this_ptr_conv;
39063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39064         this_ptr_conv.is_owned = false;
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39066         LDKChannelUpdateInfo val_conv;
39067         val_conv.inner = (void*)(val & (~1));
39068         val_conv.is_owned = (val & 1) || (val == 0);
39069         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39070         val_conv = ChannelUpdateInfo_clone(&val_conv);
39071         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39072 }
39073
39074 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
39075         LDKChannelInfo this_ptr_conv;
39076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39077         this_ptr_conv.is_owned = false;
39078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39079         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39080         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39081         uint32_t ret_ref = (uintptr_t)ret_copy;
39082         return ret_ref;
39083 }
39084
39085 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
39086         LDKChannelInfo this_ptr_conv;
39087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39088         this_ptr_conv.is_owned = false;
39089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39090         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39091         CHECK_ACCESS(val_ptr);
39092         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39093         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39094         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39095 }
39096
39097 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
39098         LDKChannelInfo this_ptr_conv;
39099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39100         this_ptr_conv.is_owned = false;
39101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39102         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39103         uint32_t ret_ref = 0;
39104         if ((uintptr_t)ret_var.inner > 4096) {
39105                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39106                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39108                 ret_ref = (uintptr_t)ret_var.inner;
39109                 if (ret_var.is_owned) {
39110                         ret_ref |= 1;
39111                 }
39112         }
39113         return ret_ref;
39114 }
39115
39116 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39117         LDKChannelInfo this_ptr_conv;
39118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39119         this_ptr_conv.is_owned = false;
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39121         LDKChannelAnnouncement val_conv;
39122         val_conv.inner = (void*)(val & (~1));
39123         val_conv.is_owned = (val & 1) || (val == 0);
39124         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39125         val_conv = ChannelAnnouncement_clone(&val_conv);
39126         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39127 }
39128
39129 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39130         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39131 uint32_t ret_ref = 0;
39132 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39133 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39134 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39135 ret_ref = (uintptr_t)ret_var.inner;
39136 if (ret_var.is_owned) {
39137         ret_ref |= 1;
39138 }
39139         return ret_ref;
39140 }
39141 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
39142         LDKChannelInfo arg_conv;
39143         arg_conv.inner = (void*)(arg & (~1));
39144         arg_conv.is_owned = false;
39145         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39146         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39147         return ret_conv;
39148 }
39149
39150 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
39151         LDKChannelInfo orig_conv;
39152         orig_conv.inner = (void*)(orig & (~1));
39153         orig_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39155         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39156         uint32_t ret_ref = 0;
39157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39160         ret_ref = (uintptr_t)ret_var.inner;
39161         if (ret_var.is_owned) {
39162                 ret_ref |= 1;
39163         }
39164         return ret_ref;
39165 }
39166
39167 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
39168         LDKChannelInfo this_arg_conv;
39169         this_arg_conv.inner = (void*)(this_arg & (~1));
39170         this_arg_conv.is_owned = false;
39171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39172         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39173         uint32_t ret_ref = 0;
39174         if ((uintptr_t)ret_var.inner > 4096) {
39175                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39176                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39178                 ret_ref = (uintptr_t)ret_var.inner;
39179                 if (ret_var.is_owned) {
39180                         ret_ref |= 1;
39181                 }
39182         }
39183         return ret_ref;
39184 }
39185
39186 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
39187         LDKChannelInfo obj_conv;
39188         obj_conv.inner = (void*)(obj & (~1));
39189         obj_conv.is_owned = false;
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39191         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39192         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39193         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39194         CVec_u8Z_free(ret_var);
39195         return ret_arr;
39196 }
39197
39198 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
39199         LDKu8slice ser_ref;
39200         ser_ref.datalen = ser->arr_len;
39201         ser_ref.data = ser->elems;
39202         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39203         *ret_conv = ChannelInfo_read(ser_ref);
39204         FREE(ser);
39205         return (uint32_t)ret_conv;
39206 }
39207
39208 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
39209         LDKDirectedChannelInfo this_obj_conv;
39210         this_obj_conv.inner = (void*)(this_obj & (~1));
39211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39213         DirectedChannelInfo_free(this_obj_conv);
39214 }
39215
39216 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39217         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39218 uint32_t ret_ref = 0;
39219 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39220 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39221 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39222 ret_ref = (uintptr_t)ret_var.inner;
39223 if (ret_var.is_owned) {
39224         ret_ref |= 1;
39225 }
39226         return ret_ref;
39227 }
39228 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
39229         LDKDirectedChannelInfo arg_conv;
39230         arg_conv.inner = (void*)(arg & (~1));
39231         arg_conv.is_owned = false;
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39233         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
39234         return ret_conv;
39235 }
39236
39237 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
39238         LDKDirectedChannelInfo orig_conv;
39239         orig_conv.inner = (void*)(orig & (~1));
39240         orig_conv.is_owned = false;
39241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39242         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39243         uint32_t ret_ref = 0;
39244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39247         ret_ref = (uintptr_t)ret_var.inner;
39248         if (ret_var.is_owned) {
39249                 ret_ref |= 1;
39250         }
39251         return ret_ref;
39252 }
39253
39254 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
39255         LDKDirectedChannelInfo this_arg_conv;
39256         this_arg_conv.inner = (void*)(this_arg & (~1));
39257         this_arg_conv.is_owned = false;
39258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39259         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39260         uint32_t ret_ref = 0;
39261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39264         ret_ref = (uintptr_t)ret_var.inner;
39265         if (ret_var.is_owned) {
39266                 ret_ref |= 1;
39267         }
39268         return ret_ref;
39269 }
39270
39271 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
39272         LDKDirectedChannelInfo this_arg_conv;
39273         this_arg_conv.inner = (void*)(this_arg & (~1));
39274         this_arg_conv.is_owned = false;
39275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39276         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
39277         uint32_t ret_ref = 0;
39278         if ((uintptr_t)ret_var.inner > 4096) {
39279                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39280                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39282                 ret_ref = (uintptr_t)ret_var.inner;
39283                 if (ret_var.is_owned) {
39284                         ret_ref |= 1;
39285                 }
39286         }
39287         return ret_ref;
39288 }
39289
39290 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
39291         LDKDirectedChannelInfo this_arg_conv;
39292         this_arg_conv.inner = (void*)(this_arg & (~1));
39293         this_arg_conv.is_owned = false;
39294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39295         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
39296         return ret_conv;
39297 }
39298
39299 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
39300         LDKDirectedChannelInfo this_arg_conv;
39301         this_arg_conv.inner = (void*)(this_arg & (~1));
39302         this_arg_conv.is_owned = false;
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39304         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39305         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
39306         uint32_t ret_ref = (uintptr_t)ret_copy;
39307         return ret_ref;
39308 }
39309
39310 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
39311         if ((this_ptr & 1) != 0) return;
39312         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39313         CHECK_ACCESS(this_ptr_ptr);
39314         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
39315         FREE((void*)this_ptr);
39316         EffectiveCapacity_free(this_ptr_conv);
39317 }
39318
39319 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
39320         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39321         *ret_copy = EffectiveCapacity_clone(arg);
39322 uint32_t ret_ref = (uintptr_t)ret_copy;
39323         return ret_ref;
39324 }
39325 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
39326         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
39327         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
39328         return ret_conv;
39329 }
39330
39331 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
39332         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
39333         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39334         *ret_copy = EffectiveCapacity_clone(orig_conv);
39335         uint32_t ret_ref = (uintptr_t)ret_copy;
39336         return ret_ref;
39337 }
39338
39339 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
39340         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39341         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
39342         uint32_t ret_ref = (uintptr_t)ret_copy;
39343         return ret_ref;
39344 }
39345
39346 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
39347         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39348         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
39349         uint32_t ret_ref = (uintptr_t)ret_copy;
39350         return ret_ref;
39351 }
39352
39353 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint32_t htlc_maximum_msat) {
39354         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
39355         CHECK_ACCESS(htlc_maximum_msat_ptr);
39356         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
39357         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
39358         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39359         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
39360         uint32_t ret_ref = (uintptr_t)ret_copy;
39361         return ret_ref;
39362 }
39363
39364 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
39365         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39366         *ret_copy = EffectiveCapacity_infinite();
39367         uint32_t ret_ref = (uintptr_t)ret_copy;
39368         return ret_ref;
39369 }
39370
39371 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
39372         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39373         *ret_copy = EffectiveCapacity_unknown();
39374         uint32_t ret_ref = (uintptr_t)ret_copy;
39375         return ret_ref;
39376 }
39377
39378 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
39379         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
39380         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
39381         return ret_conv;
39382 }
39383
39384 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
39385         LDKRoutingFees this_obj_conv;
39386         this_obj_conv.inner = (void*)(this_obj & (~1));
39387         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39389         RoutingFees_free(this_obj_conv);
39390 }
39391
39392 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
39393         LDKRoutingFees this_ptr_conv;
39394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39395         this_ptr_conv.is_owned = false;
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39397         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
39398         return ret_conv;
39399 }
39400
39401 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
39402         LDKRoutingFees this_ptr_conv;
39403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39404         this_ptr_conv.is_owned = false;
39405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39406         RoutingFees_set_base_msat(&this_ptr_conv, val);
39407 }
39408
39409 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
39410         LDKRoutingFees this_ptr_conv;
39411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39412         this_ptr_conv.is_owned = false;
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39414         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
39415         return ret_conv;
39416 }
39417
39418 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
39419         LDKRoutingFees this_ptr_conv;
39420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39421         this_ptr_conv.is_owned = false;
39422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39423         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
39424 }
39425
39426 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
39427         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
39428         uint32_t ret_ref = 0;
39429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39432         ret_ref = (uintptr_t)ret_var.inner;
39433         if (ret_var.is_owned) {
39434                 ret_ref |= 1;
39435         }
39436         return ret_ref;
39437 }
39438
39439 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
39440         LDKRoutingFees a_conv;
39441         a_conv.inner = (void*)(a & (~1));
39442         a_conv.is_owned = false;
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39444         LDKRoutingFees b_conv;
39445         b_conv.inner = (void*)(b & (~1));
39446         b_conv.is_owned = false;
39447         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39448         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
39449         return ret_conv;
39450 }
39451
39452 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
39453         LDKRoutingFees ret_var = RoutingFees_clone(arg);
39454 uint32_t ret_ref = 0;
39455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39458 ret_ref = (uintptr_t)ret_var.inner;
39459 if (ret_var.is_owned) {
39460         ret_ref |= 1;
39461 }
39462         return ret_ref;
39463 }
39464 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
39465         LDKRoutingFees arg_conv;
39466         arg_conv.inner = (void*)(arg & (~1));
39467         arg_conv.is_owned = false;
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39469         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
39470         return ret_conv;
39471 }
39472
39473 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
39474         LDKRoutingFees orig_conv;
39475         orig_conv.inner = (void*)(orig & (~1));
39476         orig_conv.is_owned = false;
39477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39478         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
39479         uint32_t ret_ref = 0;
39480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39483         ret_ref = (uintptr_t)ret_var.inner;
39484         if (ret_var.is_owned) {
39485                 ret_ref |= 1;
39486         }
39487         return ret_ref;
39488 }
39489
39490 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
39491         LDKRoutingFees o_conv;
39492         o_conv.inner = (void*)(o & (~1));
39493         o_conv.is_owned = false;
39494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39495         int64_t ret_conv = RoutingFees_hash(&o_conv);
39496         return ret_conv;
39497 }
39498
39499 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
39500         LDKRoutingFees obj_conv;
39501         obj_conv.inner = (void*)(obj & (~1));
39502         obj_conv.is_owned = false;
39503         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39504         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
39505         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39506         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39507         CVec_u8Z_free(ret_var);
39508         return ret_arr;
39509 }
39510
39511 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
39512         LDKu8slice ser_ref;
39513         ser_ref.datalen = ser->arr_len;
39514         ser_ref.data = ser->elems;
39515         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
39516         *ret_conv = RoutingFees_read(ser_ref);
39517         FREE(ser);
39518         return (uint32_t)ret_conv;
39519 }
39520
39521 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
39522         LDKNodeAnnouncementInfo this_obj_conv;
39523         this_obj_conv.inner = (void*)(this_obj & (~1));
39524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39526         NodeAnnouncementInfo_free(this_obj_conv);
39527 }
39528
39529 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
39530         LDKNodeAnnouncementInfo this_ptr_conv;
39531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39532         this_ptr_conv.is_owned = false;
39533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39534         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
39535         uint32_t ret_ref = 0;
39536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39539         ret_ref = (uintptr_t)ret_var.inner;
39540         if (ret_var.is_owned) {
39541                 ret_ref |= 1;
39542         }
39543         return ret_ref;
39544 }
39545
39546 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
39547         LDKNodeAnnouncementInfo this_ptr_conv;
39548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39549         this_ptr_conv.is_owned = false;
39550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39551         LDKNodeFeatures val_conv;
39552         val_conv.inner = (void*)(val & (~1));
39553         val_conv.is_owned = (val & 1) || (val == 0);
39554         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39555         val_conv = NodeFeatures_clone(&val_conv);
39556         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
39557 }
39558
39559 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
39560         LDKNodeAnnouncementInfo this_ptr_conv;
39561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39562         this_ptr_conv.is_owned = false;
39563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39564         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
39565         return ret_conv;
39566 }
39567
39568 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39569         LDKNodeAnnouncementInfo this_ptr_conv;
39570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39571         this_ptr_conv.is_owned = false;
39572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39573         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
39574 }
39575
39576 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
39577         LDKNodeAnnouncementInfo this_ptr_conv;
39578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39579         this_ptr_conv.is_owned = false;
39580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39581         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
39582         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
39583         return ret_arr;
39584 }
39585
39586 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
39587         LDKNodeAnnouncementInfo this_ptr_conv;
39588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39589         this_ptr_conv.is_owned = false;
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39591         LDKThreeBytes val_ref;
39592         CHECK(val->arr_len == 3);
39593         memcpy(val_ref.data, val->elems, 3); FREE(val);
39594         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
39595 }
39596
39597 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
39598         LDKNodeAnnouncementInfo this_ptr_conv;
39599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39600         this_ptr_conv.is_owned = false;
39601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39602         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
39603         uint32_t ret_ref = 0;
39604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39607         ret_ref = (uintptr_t)ret_var.inner;
39608         if (ret_var.is_owned) {
39609                 ret_ref |= 1;
39610         }
39611         return ret_ref;
39612 }
39613
39614 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, uint32_t val) {
39615         LDKNodeAnnouncementInfo this_ptr_conv;
39616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39617         this_ptr_conv.is_owned = false;
39618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39619         LDKNodeAlias val_conv;
39620         val_conv.inner = (void*)(val & (~1));
39621         val_conv.is_owned = (val & 1) || (val == 0);
39622         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39623         val_conv = NodeAlias_clone(&val_conv);
39624         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
39625 }
39626
39627 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
39628         LDKNodeAnnouncementInfo this_ptr_conv;
39629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39630         this_ptr_conv.is_owned = false;
39631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39632         LDKCVec_NetAddressZ val_constr;
39633         val_constr.datalen = val->arr_len;
39634         if (val_constr.datalen > 0)
39635                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39636         else
39637                 val_constr.data = NULL;
39638         uint32_t* val_vals = val->elems;
39639         for (size_t m = 0; m < val_constr.datalen; m++) {
39640                 uint32_t val_conv_12 = val_vals[m];
39641                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
39642                 CHECK_ACCESS(val_conv_12_ptr);
39643                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
39644                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
39645                 val_constr.data[m] = val_conv_12_conv;
39646         }
39647         FREE(val);
39648         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
39649 }
39650
39651 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
39652         LDKNodeAnnouncementInfo this_ptr_conv;
39653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39654         this_ptr_conv.is_owned = false;
39655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39656         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
39657         uint32_t ret_ref = 0;
39658         if ((uintptr_t)ret_var.inner > 4096) {
39659                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39660                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39662                 ret_ref = (uintptr_t)ret_var.inner;
39663                 if (ret_var.is_owned) {
39664                         ret_ref |= 1;
39665                 }
39666         }
39667         return ret_ref;
39668 }
39669
39670 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39671         LDKNodeAnnouncementInfo this_ptr_conv;
39672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39673         this_ptr_conv.is_owned = false;
39674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39675         LDKNodeAnnouncement val_conv;
39676         val_conv.inner = (void*)(val & (~1));
39677         val_conv.is_owned = (val & 1) || (val == 0);
39678         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39679         val_conv = NodeAnnouncement_clone(&val_conv);
39680         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
39681 }
39682
39683 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) {
39684         LDKNodeFeatures features_arg_conv;
39685         features_arg_conv.inner = (void*)(features_arg & (~1));
39686         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
39687         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
39688         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
39689         LDKThreeBytes rgb_arg_ref;
39690         CHECK(rgb_arg->arr_len == 3);
39691         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
39692         LDKNodeAlias alias_arg_conv;
39693         alias_arg_conv.inner = (void*)(alias_arg & (~1));
39694         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
39695         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
39696         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
39697         LDKCVec_NetAddressZ addresses_arg_constr;
39698         addresses_arg_constr.datalen = addresses_arg->arr_len;
39699         if (addresses_arg_constr.datalen > 0)
39700                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39701         else
39702                 addresses_arg_constr.data = NULL;
39703         uint32_t* addresses_arg_vals = addresses_arg->elems;
39704         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
39705                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
39706                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
39707                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
39708                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
39709                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
39710         }
39711         FREE(addresses_arg);
39712         LDKNodeAnnouncement announcement_message_arg_conv;
39713         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
39714         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
39715         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
39716         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
39717         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
39718         uint32_t ret_ref = 0;
39719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39722         ret_ref = (uintptr_t)ret_var.inner;
39723         if (ret_var.is_owned) {
39724                 ret_ref |= 1;
39725         }
39726         return ret_ref;
39727 }
39728
39729 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
39730         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
39731 uint32_t ret_ref = 0;
39732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39735 ret_ref = (uintptr_t)ret_var.inner;
39736 if (ret_var.is_owned) {
39737         ret_ref |= 1;
39738 }
39739         return ret_ref;
39740 }
39741 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
39742         LDKNodeAnnouncementInfo arg_conv;
39743         arg_conv.inner = (void*)(arg & (~1));
39744         arg_conv.is_owned = false;
39745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39746         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
39747         return ret_conv;
39748 }
39749
39750 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
39751         LDKNodeAnnouncementInfo orig_conv;
39752         orig_conv.inner = (void*)(orig & (~1));
39753         orig_conv.is_owned = false;
39754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39755         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
39756         uint32_t ret_ref = 0;
39757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39760         ret_ref = (uintptr_t)ret_var.inner;
39761         if (ret_var.is_owned) {
39762                 ret_ref |= 1;
39763         }
39764         return ret_ref;
39765 }
39766
39767 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
39768         LDKNodeAnnouncementInfo obj_conv;
39769         obj_conv.inner = (void*)(obj & (~1));
39770         obj_conv.is_owned = false;
39771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39772         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
39773         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39774         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39775         CVec_u8Z_free(ret_var);
39776         return ret_arr;
39777 }
39778
39779 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
39780         LDKu8slice ser_ref;
39781         ser_ref.datalen = ser->arr_len;
39782         ser_ref.data = ser->elems;
39783         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
39784         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
39785         FREE(ser);
39786         return (uint32_t)ret_conv;
39787 }
39788
39789 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint32_t this_obj) {
39790         LDKNodeAlias this_obj_conv;
39791         this_obj_conv.inner = (void*)(this_obj & (~1));
39792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39794         NodeAlias_free(this_obj_conv);
39795 }
39796
39797 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint32_t this_ptr) {
39798         LDKNodeAlias this_ptr_conv;
39799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39800         this_ptr_conv.is_owned = false;
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39802         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39803         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
39804         return ret_arr;
39805 }
39806
39807 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint32_t this_ptr, int8_tArray val) {
39808         LDKNodeAlias this_ptr_conv;
39809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39810         this_ptr_conv.is_owned = false;
39811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39812         LDKThirtyTwoBytes val_ref;
39813         CHECK(val->arr_len == 32);
39814         memcpy(val_ref.data, val->elems, 32); FREE(val);
39815         NodeAlias_set_a(&this_ptr_conv, val_ref);
39816 }
39817
39818 uint32_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
39819         LDKThirtyTwoBytes a_arg_ref;
39820         CHECK(a_arg->arr_len == 32);
39821         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
39822         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
39823         uint32_t ret_ref = 0;
39824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39827         ret_ref = (uintptr_t)ret_var.inner;
39828         if (ret_var.is_owned) {
39829                 ret_ref |= 1;
39830         }
39831         return ret_ref;
39832 }
39833
39834 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
39835         LDKNodeAlias ret_var = NodeAlias_clone(arg);
39836 uint32_t ret_ref = 0;
39837 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39838 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39839 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39840 ret_ref = (uintptr_t)ret_var.inner;
39841 if (ret_var.is_owned) {
39842         ret_ref |= 1;
39843 }
39844         return ret_ref;
39845 }
39846 uint32_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint32_t arg) {
39847         LDKNodeAlias arg_conv;
39848         arg_conv.inner = (void*)(arg & (~1));
39849         arg_conv.is_owned = false;
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39851         uint32_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
39852         return ret_conv;
39853 }
39854
39855 uint32_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint32_t orig) {
39856         LDKNodeAlias orig_conv;
39857         orig_conv.inner = (void*)(orig & (~1));
39858         orig_conv.is_owned = false;
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39860         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
39861         uint32_t ret_ref = 0;
39862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39865         ret_ref = (uintptr_t)ret_var.inner;
39866         if (ret_var.is_owned) {
39867                 ret_ref |= 1;
39868         }
39869         return ret_ref;
39870 }
39871
39872 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint32_t obj) {
39873         LDKNodeAlias 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 = NodeAlias_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_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
39885         LDKu8slice ser_ref;
39886         ser_ref.datalen = ser->arr_len;
39887         ser_ref.data = ser->elems;
39888         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
39889         *ret_conv = NodeAlias_read(ser_ref);
39890         FREE(ser);
39891         return (uint32_t)ret_conv;
39892 }
39893
39894 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
39895         LDKNodeInfo 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         NodeInfo_free(this_obj_conv);
39900 }
39901
39902 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
39903         LDKNodeInfo this_ptr_conv;
39904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39905         this_ptr_conv.is_owned = false;
39906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39907         LDKCVec_u64Z val_constr;
39908         val_constr.datalen = val->arr_len;
39909         if (val_constr.datalen > 0)
39910                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39911         else
39912                 val_constr.data = NULL;
39913         int64_t* val_vals = val->elems;
39914         for (size_t i = 0; i < val_constr.datalen; i++) {
39915                 int64_t val_conv_8 = val_vals[i];
39916                 val_constr.data[i] = val_conv_8;
39917         }
39918         FREE(val);
39919         NodeInfo_set_channels(&this_ptr_conv, val_constr);
39920 }
39921
39922 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
39923         LDKNodeInfo this_ptr_conv;
39924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39925         this_ptr_conv.is_owned = false;
39926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39927         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
39928         uint32_t ret_ref = 0;
39929         if ((uintptr_t)ret_var.inner > 4096) {
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         }
39938         return ret_ref;
39939 }
39940
39941 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) {
39942         LDKNodeInfo this_ptr_conv;
39943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39944         this_ptr_conv.is_owned = false;
39945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39946         LDKRoutingFees val_conv;
39947         val_conv.inner = (void*)(val & (~1));
39948         val_conv.is_owned = (val & 1) || (val == 0);
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39950         val_conv = RoutingFees_clone(&val_conv);
39951         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
39952 }
39953
39954 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
39955         LDKNodeInfo this_ptr_conv;
39956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39957         this_ptr_conv.is_owned = false;
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39959         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
39960         uint32_t ret_ref = 0;
39961         if ((uintptr_t)ret_var.inner > 4096) {
39962                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39963                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39965                 ret_ref = (uintptr_t)ret_var.inner;
39966                 if (ret_var.is_owned) {
39967                         ret_ref |= 1;
39968                 }
39969         }
39970         return ret_ref;
39971 }
39972
39973 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
39974         LDKNodeInfo this_ptr_conv;
39975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39976         this_ptr_conv.is_owned = false;
39977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39978         LDKNodeAnnouncementInfo val_conv;
39979         val_conv.inner = (void*)(val & (~1));
39980         val_conv.is_owned = (val & 1) || (val == 0);
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39982         val_conv = NodeAnnouncementInfo_clone(&val_conv);
39983         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
39984 }
39985
39986 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) {
39987         LDKCVec_u64Z channels_arg_constr;
39988         channels_arg_constr.datalen = channels_arg->arr_len;
39989         if (channels_arg_constr.datalen > 0)
39990                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39991         else
39992                 channels_arg_constr.data = NULL;
39993         int64_t* channels_arg_vals = channels_arg->elems;
39994         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
39995                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
39996                 channels_arg_constr.data[i] = channels_arg_conv_8;
39997         }
39998         FREE(channels_arg);
39999         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40000         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40001         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40002         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40003         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40004         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40005         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40006         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40007         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40008         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40009         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40010         uint32_t ret_ref = 0;
40011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40014         ret_ref = (uintptr_t)ret_var.inner;
40015         if (ret_var.is_owned) {
40016                 ret_ref |= 1;
40017         }
40018         return ret_ref;
40019 }
40020
40021 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40022         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40023 uint32_t ret_ref = 0;
40024 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40025 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40026 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40027 ret_ref = (uintptr_t)ret_var.inner;
40028 if (ret_var.is_owned) {
40029         ret_ref |= 1;
40030 }
40031         return ret_ref;
40032 }
40033 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
40034         LDKNodeInfo arg_conv;
40035         arg_conv.inner = (void*)(arg & (~1));
40036         arg_conv.is_owned = false;
40037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40038         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40039         return ret_conv;
40040 }
40041
40042 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
40043         LDKNodeInfo orig_conv;
40044         orig_conv.inner = (void*)(orig & (~1));
40045         orig_conv.is_owned = false;
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40047         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40048         uint32_t ret_ref = 0;
40049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40052         ret_ref = (uintptr_t)ret_var.inner;
40053         if (ret_var.is_owned) {
40054                 ret_ref |= 1;
40055         }
40056         return ret_ref;
40057 }
40058
40059 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
40060         LDKNodeInfo obj_conv;
40061         obj_conv.inner = (void*)(obj & (~1));
40062         obj_conv.is_owned = false;
40063         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40064         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40065         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40066         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40067         CVec_u8Z_free(ret_var);
40068         return ret_arr;
40069 }
40070
40071 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40072         LDKu8slice ser_ref;
40073         ser_ref.datalen = ser->arr_len;
40074         ser_ref.data = ser->elems;
40075         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40076         *ret_conv = NodeInfo_read(ser_ref);
40077         FREE(ser);
40078         return (uint32_t)ret_conv;
40079 }
40080
40081 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
40082         LDKNetworkGraph obj_conv;
40083         obj_conv.inner = (void*)(obj & (~1));
40084         obj_conv.is_owned = false;
40085         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40086         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40087         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40088         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40089         CVec_u8Z_free(ret_var);
40090         return ret_arr;
40091 }
40092
40093 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
40094         LDKu8slice ser_ref;
40095         ser_ref.datalen = ser->arr_len;
40096         ser_ref.data = ser->elems;
40097         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
40098         CHECK_ACCESS(arg_ptr);
40099         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40100         if (arg_conv.free == LDKLogger_JCalls_free) {
40101                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40102                 LDKLogger_JCalls_cloned(&arg_conv);
40103         }
40104         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40105         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40106         FREE(ser);
40107         return (uint32_t)ret_conv;
40108 }
40109
40110 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
40111         LDKThirtyTwoBytes genesis_hash_ref;
40112         CHECK(genesis_hash->arr_len == 32);
40113         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40114         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40115         CHECK_ACCESS(logger_ptr);
40116         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40117         if (logger_conv.free == LDKLogger_JCalls_free) {
40118                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40119                 LDKLogger_JCalls_cloned(&logger_conv);
40120         }
40121         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40122         uint32_t ret_ref = 0;
40123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40126         ret_ref = (uintptr_t)ret_var.inner;
40127         if (ret_var.is_owned) {
40128                 ret_ref |= 1;
40129         }
40130         return ret_ref;
40131 }
40132
40133 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
40134         LDKNetworkGraph this_arg_conv;
40135         this_arg_conv.inner = (void*)(this_arg & (~1));
40136         this_arg_conv.is_owned = false;
40137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40138         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40139         uint32_t ret_ref = 0;
40140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40143         ret_ref = (uintptr_t)ret_var.inner;
40144         if (ret_var.is_owned) {
40145                 ret_ref |= 1;
40146         }
40147         return ret_ref;
40148 }
40149
40150 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) {
40151         LDKNetworkGraph this_arg_conv;
40152         this_arg_conv.inner = (void*)(this_arg & (~1));
40153         this_arg_conv.is_owned = false;
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40155         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
40156         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
40157         uint32_t ret_ref = (uintptr_t)ret_copy;
40158         return ret_ref;
40159 }
40160
40161 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) {
40162         LDKNetworkGraph this_arg_conv;
40163         this_arg_conv.inner = (void*)(this_arg & (~1));
40164         this_arg_conv.is_owned = false;
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40166         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
40167 }
40168
40169 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
40170         LDKNetworkGraph this_arg_conv;
40171         this_arg_conv.inner = (void*)(this_arg & (~1));
40172         this_arg_conv.is_owned = false;
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40174         LDKNodeAnnouncement msg_conv;
40175         msg_conv.inner = (void*)(msg & (~1));
40176         msg_conv.is_owned = false;
40177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40178         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40179         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40180         return (uint32_t)ret_conv;
40181 }
40182
40183 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) {
40184         LDKNetworkGraph this_arg_conv;
40185         this_arg_conv.inner = (void*)(this_arg & (~1));
40186         this_arg_conv.is_owned = false;
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40188         LDKUnsignedNodeAnnouncement msg_conv;
40189         msg_conv.inner = (void*)(msg & (~1));
40190         msg_conv.is_owned = false;
40191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40192         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40193         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40194         return (uint32_t)ret_conv;
40195 }
40196
40197 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) {
40198         LDKNetworkGraph this_arg_conv;
40199         this_arg_conv.inner = (void*)(this_arg & (~1));
40200         this_arg_conv.is_owned = false;
40201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40202         LDKChannelAnnouncement msg_conv;
40203         msg_conv.inner = (void*)(msg & (~1));
40204         msg_conv.is_owned = false;
40205         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40206         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40207         CHECK_ACCESS(chain_access_ptr);
40208         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40209         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40210         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40211                 // Manually implement clone for Java trait instances
40212                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40213                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40214                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40215                 }
40216         }
40217         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40218         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40219         return (uint32_t)ret_conv;
40220 }
40221
40222 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) {
40223         LDKNetworkGraph this_arg_conv;
40224         this_arg_conv.inner = (void*)(this_arg & (~1));
40225         this_arg_conv.is_owned = false;
40226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40227         LDKUnsignedChannelAnnouncement msg_conv;
40228         msg_conv.inner = (void*)(msg & (~1));
40229         msg_conv.is_owned = false;
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40231         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40232         CHECK_ACCESS(chain_access_ptr);
40233         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40234         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40235         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40236                 // Manually implement clone for Java trait instances
40237                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40238                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40239                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40240                 }
40241         }
40242         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40243         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40244         return (uint32_t)ret_conv;
40245 }
40246
40247 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) {
40248         LDKNetworkGraph this_arg_conv;
40249         this_arg_conv.inner = (void*)(this_arg & (~1));
40250         this_arg_conv.is_owned = false;
40251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40252         LDKChannelFeatures features_conv;
40253         features_conv.inner = (void*)(features & (~1));
40254         features_conv.is_owned = (features & 1) || (features == 0);
40255         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
40256         features_conv = ChannelFeatures_clone(&features_conv);
40257         LDKPublicKey node_id_1_ref;
40258         CHECK(node_id_1->arr_len == 33);
40259         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
40260         LDKPublicKey node_id_2_ref;
40261         CHECK(node_id_2->arr_len == 33);
40262         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
40263         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40264         *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);
40265         return (uint32_t)ret_conv;
40266 }
40267
40268 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40269         LDKNetworkGraph this_arg_conv;
40270         this_arg_conv.inner = (void*)(this_arg & (~1));
40271         this_arg_conv.is_owned = false;
40272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40273         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
40274 }
40275
40276 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40277         LDKNetworkGraph this_arg_conv;
40278         this_arg_conv.inner = (void*)(this_arg & (~1));
40279         this_arg_conv.is_owned = false;
40280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40281         LDKPublicKey _node_id_ref;
40282         CHECK(_node_id->arr_len == 33);
40283         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
40284         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
40285 }
40286
40287 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) {
40288         LDKNetworkGraph this_arg_conv;
40289         this_arg_conv.inner = (void*)(this_arg & (~1));
40290         this_arg_conv.is_owned = false;
40291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40292         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
40293 }
40294
40295 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
40296         LDKNetworkGraph this_arg_conv;
40297         this_arg_conv.inner = (void*)(this_arg & (~1));
40298         this_arg_conv.is_owned = false;
40299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40300         LDKChannelUpdate msg_conv;
40301         msg_conv.inner = (void*)(msg & (~1));
40302         msg_conv.is_owned = false;
40303         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40304         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40305         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
40306         return (uint32_t)ret_conv;
40307 }
40308
40309 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
40310         LDKNetworkGraph this_arg_conv;
40311         this_arg_conv.inner = (void*)(this_arg & (~1));
40312         this_arg_conv.is_owned = false;
40313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40314         LDKUnsignedChannelUpdate msg_conv;
40315         msg_conv.inner = (void*)(msg & (~1));
40316         msg_conv.is_owned = false;
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40318         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40319         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
40320         return (uint32_t)ret_conv;
40321 }
40322
40323 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
40324         LDKReadOnlyNetworkGraph this_arg_conv;
40325         this_arg_conv.inner = (void*)(this_arg & (~1));
40326         this_arg_conv.is_owned = false;
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40328         LDKPublicKey pubkey_ref;
40329         CHECK(pubkey->arr_len == 33);
40330         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
40331         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
40332         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
40333         uint32_t ret_ref = (uintptr_t)ret_copy;
40334         return ret_ref;
40335 }
40336
40337 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
40338         LDKRouteHop this_obj_conv;
40339         this_obj_conv.inner = (void*)(this_obj & (~1));
40340         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40342         RouteHop_free(this_obj_conv);
40343 }
40344
40345 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
40346         LDKRouteHop this_ptr_conv;
40347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40348         this_ptr_conv.is_owned = false;
40349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40350         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40351         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
40352         return ret_arr;
40353 }
40354
40355 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
40356         LDKRouteHop this_ptr_conv;
40357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40358         this_ptr_conv.is_owned = false;
40359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40360         LDKPublicKey val_ref;
40361         CHECK(val->arr_len == 33);
40362         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40363         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
40364 }
40365
40366 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
40367         LDKRouteHop this_ptr_conv;
40368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40369         this_ptr_conv.is_owned = false;
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40371         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
40372         uint32_t ret_ref = 0;
40373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40376         ret_ref = (uintptr_t)ret_var.inner;
40377         if (ret_var.is_owned) {
40378                 ret_ref |= 1;
40379         }
40380         return ret_ref;
40381 }
40382
40383 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
40384         LDKRouteHop this_ptr_conv;
40385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40386         this_ptr_conv.is_owned = false;
40387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40388         LDKNodeFeatures val_conv;
40389         val_conv.inner = (void*)(val & (~1));
40390         val_conv.is_owned = (val & 1) || (val == 0);
40391         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40392         val_conv = NodeFeatures_clone(&val_conv);
40393         RouteHop_set_node_features(&this_ptr_conv, val_conv);
40394 }
40395
40396 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
40397         LDKRouteHop this_ptr_conv;
40398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40399         this_ptr_conv.is_owned = false;
40400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40401         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
40402         return ret_conv;
40403 }
40404
40405 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
40406         LDKRouteHop this_ptr_conv;
40407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40408         this_ptr_conv.is_owned = false;
40409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40410         RouteHop_set_short_channel_id(&this_ptr_conv, val);
40411 }
40412
40413 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
40414         LDKRouteHop this_ptr_conv;
40415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40416         this_ptr_conv.is_owned = false;
40417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40418         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
40419         uint32_t ret_ref = 0;
40420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40423         ret_ref = (uintptr_t)ret_var.inner;
40424         if (ret_var.is_owned) {
40425                 ret_ref |= 1;
40426         }
40427         return ret_ref;
40428 }
40429
40430 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
40431         LDKRouteHop this_ptr_conv;
40432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40433         this_ptr_conv.is_owned = false;
40434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40435         LDKChannelFeatures val_conv;
40436         val_conv.inner = (void*)(val & (~1));
40437         val_conv.is_owned = (val & 1) || (val == 0);
40438         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40439         val_conv = ChannelFeatures_clone(&val_conv);
40440         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
40441 }
40442
40443 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
40444         LDKRouteHop this_ptr_conv;
40445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40446         this_ptr_conv.is_owned = false;
40447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40448         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
40449         return ret_conv;
40450 }
40451
40452 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
40453         LDKRouteHop this_ptr_conv;
40454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40455         this_ptr_conv.is_owned = false;
40456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40457         RouteHop_set_fee_msat(&this_ptr_conv, val);
40458 }
40459
40460 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
40461         LDKRouteHop this_ptr_conv;
40462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40463         this_ptr_conv.is_owned = false;
40464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40465         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
40466         return ret_conv;
40467 }
40468
40469 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
40470         LDKRouteHop this_ptr_conv;
40471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40472         this_ptr_conv.is_owned = false;
40473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40474         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
40475 }
40476
40477 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) {
40478         LDKPublicKey pubkey_arg_ref;
40479         CHECK(pubkey_arg->arr_len == 33);
40480         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
40481         LDKNodeFeatures node_features_arg_conv;
40482         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
40483         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
40485         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
40486         LDKChannelFeatures channel_features_arg_conv;
40487         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
40488         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
40489         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
40490         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
40491         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);
40492         uint32_t ret_ref = 0;
40493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40496         ret_ref = (uintptr_t)ret_var.inner;
40497         if (ret_var.is_owned) {
40498                 ret_ref |= 1;
40499         }
40500         return ret_ref;
40501 }
40502
40503 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
40504         LDKRouteHop ret_var = RouteHop_clone(arg);
40505 uint32_t ret_ref = 0;
40506 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40507 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40508 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40509 ret_ref = (uintptr_t)ret_var.inner;
40510 if (ret_var.is_owned) {
40511         ret_ref |= 1;
40512 }
40513         return ret_ref;
40514 }
40515 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
40516         LDKRouteHop arg_conv;
40517         arg_conv.inner = (void*)(arg & (~1));
40518         arg_conv.is_owned = false;
40519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40520         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
40521         return ret_conv;
40522 }
40523
40524 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
40525         LDKRouteHop orig_conv;
40526         orig_conv.inner = (void*)(orig & (~1));
40527         orig_conv.is_owned = false;
40528         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40529         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
40530         uint32_t ret_ref = 0;
40531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40534         ret_ref = (uintptr_t)ret_var.inner;
40535         if (ret_var.is_owned) {
40536                 ret_ref |= 1;
40537         }
40538         return ret_ref;
40539 }
40540
40541 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
40542         LDKRouteHop o_conv;
40543         o_conv.inner = (void*)(o & (~1));
40544         o_conv.is_owned = false;
40545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40546         int64_t ret_conv = RouteHop_hash(&o_conv);
40547         return ret_conv;
40548 }
40549
40550 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
40551         LDKRouteHop a_conv;
40552         a_conv.inner = (void*)(a & (~1));
40553         a_conv.is_owned = false;
40554         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40555         LDKRouteHop b_conv;
40556         b_conv.inner = (void*)(b & (~1));
40557         b_conv.is_owned = false;
40558         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40559         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
40560         return ret_conv;
40561 }
40562
40563 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
40564         LDKRouteHop obj_conv;
40565         obj_conv.inner = (void*)(obj & (~1));
40566         obj_conv.is_owned = false;
40567         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40568         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
40569         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40570         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40571         CVec_u8Z_free(ret_var);
40572         return ret_arr;
40573 }
40574
40575 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
40576         LDKu8slice ser_ref;
40577         ser_ref.datalen = ser->arr_len;
40578         ser_ref.data = ser->elems;
40579         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
40580         *ret_conv = RouteHop_read(ser_ref);
40581         FREE(ser);
40582         return (uint32_t)ret_conv;
40583 }
40584
40585 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
40586         LDKRoute this_obj_conv;
40587         this_obj_conv.inner = (void*)(this_obj & (~1));
40588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40590         Route_free(this_obj_conv);
40591 }
40592
40593 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
40594         LDKRoute this_ptr_conv;
40595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40596         this_ptr_conv.is_owned = false;
40597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40598         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
40599         ptrArray ret_arr = NULL;
40600         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
40601         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
40602         for (size_t m = 0; m < ret_var.datalen; m++) {
40603                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
40604                 uint32_tArray ret_conv_12_arr = NULL;
40605                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
40606                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
40607                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
40608                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
40609                         uint32_t ret_conv_12_conv_10_ref = 0;
40610                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40611                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40612                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
40613                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
40614                         if (ret_conv_12_conv_10_var.is_owned) {
40615                                 ret_conv_12_conv_10_ref |= 1;
40616                         }
40617                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
40618                 }
40619                 
40620                 FREE(ret_conv_12_var.data);
40621                 ret_arr_ptr[m] = ret_conv_12_arr;
40622         }
40623         
40624         FREE(ret_var.data);
40625         return ret_arr;
40626 }
40627
40628 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
40629         LDKRoute this_ptr_conv;
40630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40631         this_ptr_conv.is_owned = false;
40632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40633         LDKCVec_CVec_RouteHopZZ val_constr;
40634         val_constr.datalen = val->arr_len;
40635         if (val_constr.datalen > 0)
40636                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
40637         else
40638                 val_constr.data = NULL;
40639         uint32_tArray* val_vals = (void*) val->elems;
40640         for (size_t m = 0; m < val_constr.datalen; m++) {
40641                 uint32_tArray val_conv_12 = val_vals[m];
40642                 LDKCVec_RouteHopZ val_conv_12_constr;
40643                 val_conv_12_constr.datalen = val_conv_12->arr_len;
40644                 if (val_conv_12_constr.datalen > 0)
40645                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
40646                 else
40647                         val_conv_12_constr.data = NULL;
40648                 uint32_t* val_conv_12_vals = val_conv_12->elems;
40649                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
40650                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
40651                         LDKRouteHop val_conv_12_conv_10_conv;
40652                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
40653                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
40654                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
40655                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
40656                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
40657                 }
40658                 FREE(val_conv_12);
40659                 val_constr.data[m] = val_conv_12_constr;
40660         }
40661         FREE(val);
40662         Route_set_paths(&this_ptr_conv, val_constr);
40663 }
40664
40665 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
40666         LDKRoute this_ptr_conv;
40667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40668         this_ptr_conv.is_owned = false;
40669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40670         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
40671         uint32_t ret_ref = 0;
40672         if ((uintptr_t)ret_var.inner > 4096) {
40673                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40674                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40676                 ret_ref = (uintptr_t)ret_var.inner;
40677                 if (ret_var.is_owned) {
40678                         ret_ref |= 1;
40679                 }
40680         }
40681         return ret_ref;
40682 }
40683
40684 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
40685         LDKRoute this_ptr_conv;
40686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40687         this_ptr_conv.is_owned = false;
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40689         LDKPaymentParameters val_conv;
40690         val_conv.inner = (void*)(val & (~1));
40691         val_conv.is_owned = (val & 1) || (val == 0);
40692         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40693         val_conv = PaymentParameters_clone(&val_conv);
40694         Route_set_payment_params(&this_ptr_conv, val_conv);
40695 }
40696
40697 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
40698         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
40699         paths_arg_constr.datalen = paths_arg->arr_len;
40700         if (paths_arg_constr.datalen > 0)
40701                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
40702         else
40703                 paths_arg_constr.data = NULL;
40704         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
40705         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
40706                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
40707                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
40708                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
40709                 if (paths_arg_conv_12_constr.datalen > 0)
40710                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
40711                 else
40712                         paths_arg_conv_12_constr.data = NULL;
40713                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
40714                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
40715                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
40716                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
40717                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
40718                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
40719                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
40720                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
40721                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
40722                 }
40723                 FREE(paths_arg_conv_12);
40724                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
40725         }
40726         FREE(paths_arg);
40727         LDKPaymentParameters payment_params_arg_conv;
40728         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40729         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40731         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40732         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
40733         uint32_t ret_ref = 0;
40734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40737         ret_ref = (uintptr_t)ret_var.inner;
40738         if (ret_var.is_owned) {
40739                 ret_ref |= 1;
40740         }
40741         return ret_ref;
40742 }
40743
40744 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
40745         LDKRoute ret_var = Route_clone(arg);
40746 uint32_t ret_ref = 0;
40747 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40748 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40749 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40750 ret_ref = (uintptr_t)ret_var.inner;
40751 if (ret_var.is_owned) {
40752         ret_ref |= 1;
40753 }
40754         return ret_ref;
40755 }
40756 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
40757         LDKRoute arg_conv;
40758         arg_conv.inner = (void*)(arg & (~1));
40759         arg_conv.is_owned = false;
40760         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40761         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
40762         return ret_conv;
40763 }
40764
40765 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
40766         LDKRoute orig_conv;
40767         orig_conv.inner = (void*)(orig & (~1));
40768         orig_conv.is_owned = false;
40769         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40770         LDKRoute ret_var = Route_clone(&orig_conv);
40771         uint32_t ret_ref = 0;
40772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40775         ret_ref = (uintptr_t)ret_var.inner;
40776         if (ret_var.is_owned) {
40777                 ret_ref |= 1;
40778         }
40779         return ret_ref;
40780 }
40781
40782 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
40783         LDKRoute o_conv;
40784         o_conv.inner = (void*)(o & (~1));
40785         o_conv.is_owned = false;
40786         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40787         int64_t ret_conv = Route_hash(&o_conv);
40788         return ret_conv;
40789 }
40790
40791 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
40792         LDKRoute a_conv;
40793         a_conv.inner = (void*)(a & (~1));
40794         a_conv.is_owned = false;
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40796         LDKRoute b_conv;
40797         b_conv.inner = (void*)(b & (~1));
40798         b_conv.is_owned = false;
40799         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40800         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
40801         return ret_conv;
40802 }
40803
40804 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
40805         LDKRoute this_arg_conv;
40806         this_arg_conv.inner = (void*)(this_arg & (~1));
40807         this_arg_conv.is_owned = false;
40808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40809         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
40810         return ret_conv;
40811 }
40812
40813 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
40814         LDKRoute this_arg_conv;
40815         this_arg_conv.inner = (void*)(this_arg & (~1));
40816         this_arg_conv.is_owned = false;
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40818         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
40819         return ret_conv;
40820 }
40821
40822 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
40823         LDKRoute obj_conv;
40824         obj_conv.inner = (void*)(obj & (~1));
40825         obj_conv.is_owned = false;
40826         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40827         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
40828         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40829         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40830         CVec_u8Z_free(ret_var);
40831         return ret_arr;
40832 }
40833
40834 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
40835         LDKu8slice ser_ref;
40836         ser_ref.datalen = ser->arr_len;
40837         ser_ref.data = ser->elems;
40838         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
40839         *ret_conv = Route_read(ser_ref);
40840         FREE(ser);
40841         return (uint32_t)ret_conv;
40842 }
40843
40844 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
40845         LDKRouteParameters this_obj_conv;
40846         this_obj_conv.inner = (void*)(this_obj & (~1));
40847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40849         RouteParameters_free(this_obj_conv);
40850 }
40851
40852 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
40853         LDKRouteParameters this_ptr_conv;
40854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40855         this_ptr_conv.is_owned = false;
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40857         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
40858         uint32_t ret_ref = 0;
40859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40862         ret_ref = (uintptr_t)ret_var.inner;
40863         if (ret_var.is_owned) {
40864                 ret_ref |= 1;
40865         }
40866         return ret_ref;
40867 }
40868
40869 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
40870         LDKRouteParameters this_ptr_conv;
40871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40872         this_ptr_conv.is_owned = false;
40873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40874         LDKPaymentParameters val_conv;
40875         val_conv.inner = (void*)(val & (~1));
40876         val_conv.is_owned = (val & 1) || (val == 0);
40877         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40878         val_conv = PaymentParameters_clone(&val_conv);
40879         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
40880 }
40881
40882 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
40883         LDKRouteParameters this_ptr_conv;
40884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40885         this_ptr_conv.is_owned = false;
40886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40887         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
40888         return ret_conv;
40889 }
40890
40891 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
40892         LDKRouteParameters this_ptr_conv;
40893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40894         this_ptr_conv.is_owned = false;
40895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40896         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
40897 }
40898
40899 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
40900         LDKRouteParameters this_ptr_conv;
40901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40902         this_ptr_conv.is_owned = false;
40903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40904         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
40905         return ret_conv;
40906 }
40907
40908 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) {
40909         LDKRouteParameters this_ptr_conv;
40910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40911         this_ptr_conv.is_owned = false;
40912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40913         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
40914 }
40915
40916 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) {
40917         LDKPaymentParameters payment_params_arg_conv;
40918         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40919         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40920         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40921         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40922         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
40923         uint32_t ret_ref = 0;
40924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40927         ret_ref = (uintptr_t)ret_var.inner;
40928         if (ret_var.is_owned) {
40929                 ret_ref |= 1;
40930         }
40931         return ret_ref;
40932 }
40933
40934 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
40935         LDKRouteParameters ret_var = RouteParameters_clone(arg);
40936 uint32_t ret_ref = 0;
40937 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40938 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40940 ret_ref = (uintptr_t)ret_var.inner;
40941 if (ret_var.is_owned) {
40942         ret_ref |= 1;
40943 }
40944         return ret_ref;
40945 }
40946 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
40947         LDKRouteParameters arg_conv;
40948         arg_conv.inner = (void*)(arg & (~1));
40949         arg_conv.is_owned = false;
40950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40951         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
40952         return ret_conv;
40953 }
40954
40955 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
40956         LDKRouteParameters orig_conv;
40957         orig_conv.inner = (void*)(orig & (~1));
40958         orig_conv.is_owned = false;
40959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40960         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
40961         uint32_t ret_ref = 0;
40962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40965         ret_ref = (uintptr_t)ret_var.inner;
40966         if (ret_var.is_owned) {
40967                 ret_ref |= 1;
40968         }
40969         return ret_ref;
40970 }
40971
40972 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
40973         LDKRouteParameters obj_conv;
40974         obj_conv.inner = (void*)(obj & (~1));
40975         obj_conv.is_owned = false;
40976         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40977         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
40978         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40979         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40980         CVec_u8Z_free(ret_var);
40981         return ret_arr;
40982 }
40983
40984 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
40985         LDKu8slice ser_ref;
40986         ser_ref.datalen = ser->arr_len;
40987         ser_ref.data = ser->elems;
40988         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
40989         *ret_conv = RouteParameters_read(ser_ref);
40990         FREE(ser);
40991         return (uint32_t)ret_conv;
40992 }
40993
40994 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
40995         LDKPaymentParameters this_obj_conv;
40996         this_obj_conv.inner = (void*)(this_obj & (~1));
40997         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40999         PaymentParameters_free(this_obj_conv);
41000 }
41001
41002 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
41003         LDKPaymentParameters this_ptr_conv;
41004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41005         this_ptr_conv.is_owned = false;
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41007         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41008         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41009         return ret_arr;
41010 }
41011
41012 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
41013         LDKPaymentParameters this_ptr_conv;
41014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41015         this_ptr_conv.is_owned = false;
41016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41017         LDKPublicKey val_ref;
41018         CHECK(val->arr_len == 33);
41019         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41020         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41021 }
41022
41023 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
41024         LDKPaymentParameters this_ptr_conv;
41025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41026         this_ptr_conv.is_owned = false;
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41028         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41029         uint32_t ret_ref = 0;
41030         if ((uintptr_t)ret_var.inner > 4096) {
41031                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41032                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41034                 ret_ref = (uintptr_t)ret_var.inner;
41035                 if (ret_var.is_owned) {
41036                         ret_ref |= 1;
41037                 }
41038         }
41039         return ret_ref;
41040 }
41041
41042 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
41043         LDKPaymentParameters this_ptr_conv;
41044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41045         this_ptr_conv.is_owned = false;
41046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41047         LDKInvoiceFeatures val_conv;
41048         val_conv.inner = (void*)(val & (~1));
41049         val_conv.is_owned = (val & 1) || (val == 0);
41050         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41051         val_conv = InvoiceFeatures_clone(&val_conv);
41052         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41053 }
41054
41055 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
41056         LDKPaymentParameters this_ptr_conv;
41057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41058         this_ptr_conv.is_owned = false;
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41060         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41061         uint32_tArray ret_arr = NULL;
41062         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41063         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41064         for (size_t l = 0; l < ret_var.datalen; l++) {
41065                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41066                 uint32_t ret_conv_11_ref = 0;
41067                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41068                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41069                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41070                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41071                 if (ret_conv_11_var.is_owned) {
41072                         ret_conv_11_ref |= 1;
41073                 }
41074                 ret_arr_ptr[l] = ret_conv_11_ref;
41075         }
41076         
41077         FREE(ret_var.data);
41078         return ret_arr;
41079 }
41080
41081 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
41082         LDKPaymentParameters this_ptr_conv;
41083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41084         this_ptr_conv.is_owned = false;
41085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41086         LDKCVec_RouteHintZ val_constr;
41087         val_constr.datalen = val->arr_len;
41088         if (val_constr.datalen > 0)
41089                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41090         else
41091                 val_constr.data = NULL;
41092         uint32_t* val_vals = val->elems;
41093         for (size_t l = 0; l < val_constr.datalen; l++) {
41094                 uint32_t val_conv_11 = val_vals[l];
41095                 LDKRouteHint val_conv_11_conv;
41096                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
41097                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
41098                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41099                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41100                 val_constr.data[l] = val_conv_11_conv;
41101         }
41102         FREE(val);
41103         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41104 }
41105
41106 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
41107         LDKPaymentParameters this_ptr_conv;
41108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41109         this_ptr_conv.is_owned = false;
41110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41111         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41112         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41113         uint32_t ret_ref = (uintptr_t)ret_copy;
41114         return ret_ref;
41115 }
41116
41117 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
41118         LDKPaymentParameters this_ptr_conv;
41119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41120         this_ptr_conv.is_owned = false;
41121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41122         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41123         CHECK_ACCESS(val_ptr);
41124         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41125         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41126         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41127 }
41128
41129 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) {
41130         LDKPaymentParameters this_ptr_conv;
41131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41132         this_ptr_conv.is_owned = false;
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41134         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41135         return ret_conv;
41136 }
41137
41138 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) {
41139         LDKPaymentParameters this_ptr_conv;
41140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41141         this_ptr_conv.is_owned = false;
41142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41143         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41144 }
41145
41146 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_mpp_path_count"))) TS_PaymentParameters_get_max_mpp_path_count(uint32_t this_ptr) {
41147         LDKPaymentParameters this_ptr_conv;
41148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41149         this_ptr_conv.is_owned = false;
41150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41151         int8_t ret_conv = PaymentParameters_get_max_mpp_path_count(&this_ptr_conv);
41152         return ret_conv;
41153 }
41154
41155 void  __attribute__((export_name("TS_PaymentParameters_set_max_mpp_path_count"))) TS_PaymentParameters_set_max_mpp_path_count(uint32_t this_ptr, int8_t val) {
41156         LDKPaymentParameters this_ptr_conv;
41157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41158         this_ptr_conv.is_owned = false;
41159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41160         PaymentParameters_set_max_mpp_path_count(&this_ptr_conv, val);
41161 }
41162
41163 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_mpp_path_count_arg) {
41164         LDKPublicKey payee_pubkey_arg_ref;
41165         CHECK(payee_pubkey_arg->arr_len == 33);
41166         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
41167         LDKInvoiceFeatures features_arg_conv;
41168         features_arg_conv.inner = (void*)(features_arg & (~1));
41169         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
41170         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41171         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41172         LDKCVec_RouteHintZ route_hints_arg_constr;
41173         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
41174         if (route_hints_arg_constr.datalen > 0)
41175                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41176         else
41177                 route_hints_arg_constr.data = NULL;
41178         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
41179         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41180                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41181                 LDKRouteHint route_hints_arg_conv_11_conv;
41182                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
41183                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
41184                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
41185                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
41186                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
41187         }
41188         FREE(route_hints_arg);
41189         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
41190         CHECK_ACCESS(expiry_time_arg_ptr);
41191         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
41192         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
41193         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_mpp_path_count_arg);
41194         uint32_t ret_ref = 0;
41195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41198         ret_ref = (uintptr_t)ret_var.inner;
41199         if (ret_var.is_owned) {
41200                 ret_ref |= 1;
41201         }
41202         return ret_ref;
41203 }
41204
41205 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
41206         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
41207 uint32_t ret_ref = 0;
41208 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41209 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41210 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41211 ret_ref = (uintptr_t)ret_var.inner;
41212 if (ret_var.is_owned) {
41213         ret_ref |= 1;
41214 }
41215         return ret_ref;
41216 }
41217 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
41218         LDKPaymentParameters arg_conv;
41219         arg_conv.inner = (void*)(arg & (~1));
41220         arg_conv.is_owned = false;
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41222         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
41223         return ret_conv;
41224 }
41225
41226 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
41227         LDKPaymentParameters orig_conv;
41228         orig_conv.inner = (void*)(orig & (~1));
41229         orig_conv.is_owned = false;
41230         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41231         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
41232         uint32_t ret_ref = 0;
41233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41236         ret_ref = (uintptr_t)ret_var.inner;
41237         if (ret_var.is_owned) {
41238                 ret_ref |= 1;
41239         }
41240         return ret_ref;
41241 }
41242
41243 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
41244         LDKPaymentParameters o_conv;
41245         o_conv.inner = (void*)(o & (~1));
41246         o_conv.is_owned = false;
41247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41248         int64_t ret_conv = PaymentParameters_hash(&o_conv);
41249         return ret_conv;
41250 }
41251
41252 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
41253         LDKPaymentParameters a_conv;
41254         a_conv.inner = (void*)(a & (~1));
41255         a_conv.is_owned = false;
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41257         LDKPaymentParameters b_conv;
41258         b_conv.inner = (void*)(b & (~1));
41259         b_conv.is_owned = false;
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41261         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
41262         return ret_conv;
41263 }
41264
41265 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
41266         LDKPaymentParameters obj_conv;
41267         obj_conv.inner = (void*)(obj & (~1));
41268         obj_conv.is_owned = false;
41269         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41270         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
41271         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41272         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41273         CVec_u8Z_free(ret_var);
41274         return ret_arr;
41275 }
41276
41277 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
41278         LDKu8slice ser_ref;
41279         ser_ref.datalen = ser->arr_len;
41280         ser_ref.data = ser->elems;
41281         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
41282         *ret_conv = PaymentParameters_read(ser_ref);
41283         FREE(ser);
41284         return (uint32_t)ret_conv;
41285 }
41286
41287 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
41288         LDKPublicKey payee_pubkey_ref;
41289         CHECK(payee_pubkey->arr_len == 33);
41290         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
41291         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
41292         uint32_t ret_ref = 0;
41293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41296         ret_ref = (uintptr_t)ret_var.inner;
41297         if (ret_var.is_owned) {
41298                 ret_ref |= 1;
41299         }
41300         return ret_ref;
41301 }
41302
41303 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
41304         LDKPublicKey payee_pubkey_ref;
41305         CHECK(payee_pubkey->arr_len == 33);
41306         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
41307         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
41308         uint32_t ret_ref = 0;
41309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41312         ret_ref = (uintptr_t)ret_var.inner;
41313         if (ret_var.is_owned) {
41314                 ret_ref |= 1;
41315         }
41316         return ret_ref;
41317 }
41318
41319 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
41320         LDKRouteHint this_obj_conv;
41321         this_obj_conv.inner = (void*)(this_obj & (~1));
41322         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41324         RouteHint_free(this_obj_conv);
41325 }
41326
41327 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
41328         LDKRouteHint this_ptr_conv;
41329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41330         this_ptr_conv.is_owned = false;
41331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41332         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
41333         uint32_tArray ret_arr = NULL;
41334         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41335         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41336         for (size_t o = 0; o < ret_var.datalen; o++) {
41337                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
41338                 uint32_t ret_conv_14_ref = 0;
41339                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41340                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41341                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41342                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41343                 if (ret_conv_14_var.is_owned) {
41344                         ret_conv_14_ref |= 1;
41345                 }
41346                 ret_arr_ptr[o] = ret_conv_14_ref;
41347         }
41348         
41349         FREE(ret_var.data);
41350         return ret_arr;
41351 }
41352
41353 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
41354         LDKRouteHint this_ptr_conv;
41355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41356         this_ptr_conv.is_owned = false;
41357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41358         LDKCVec_RouteHintHopZ val_constr;
41359         val_constr.datalen = val->arr_len;
41360         if (val_constr.datalen > 0)
41361                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41362         else
41363                 val_constr.data = NULL;
41364         uint32_t* val_vals = val->elems;
41365         for (size_t o = 0; o < val_constr.datalen; o++) {
41366                 uint32_t val_conv_14 = val_vals[o];
41367                 LDKRouteHintHop val_conv_14_conv;
41368                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
41369                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
41370                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
41371                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
41372                 val_constr.data[o] = val_conv_14_conv;
41373         }
41374         FREE(val);
41375         RouteHint_set_a(&this_ptr_conv, val_constr);
41376 }
41377
41378 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
41379         LDKCVec_RouteHintHopZ a_arg_constr;
41380         a_arg_constr.datalen = a_arg->arr_len;
41381         if (a_arg_constr.datalen > 0)
41382                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41383         else
41384                 a_arg_constr.data = NULL;
41385         uint32_t* a_arg_vals = a_arg->elems;
41386         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
41387                 uint32_t a_arg_conv_14 = a_arg_vals[o];
41388                 LDKRouteHintHop a_arg_conv_14_conv;
41389                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
41390                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
41391                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
41392                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
41393                 a_arg_constr.data[o] = a_arg_conv_14_conv;
41394         }
41395         FREE(a_arg);
41396         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
41397         uint32_t ret_ref = 0;
41398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41401         ret_ref = (uintptr_t)ret_var.inner;
41402         if (ret_var.is_owned) {
41403                 ret_ref |= 1;
41404         }
41405         return ret_ref;
41406 }
41407
41408 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
41409         LDKRouteHint ret_var = RouteHint_clone(arg);
41410 uint32_t ret_ref = 0;
41411 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41412 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41413 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41414 ret_ref = (uintptr_t)ret_var.inner;
41415 if (ret_var.is_owned) {
41416         ret_ref |= 1;
41417 }
41418         return ret_ref;
41419 }
41420 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
41421         LDKRouteHint arg_conv;
41422         arg_conv.inner = (void*)(arg & (~1));
41423         arg_conv.is_owned = false;
41424         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41425         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
41426         return ret_conv;
41427 }
41428
41429 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
41430         LDKRouteHint orig_conv;
41431         orig_conv.inner = (void*)(orig & (~1));
41432         orig_conv.is_owned = false;
41433         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41434         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
41435         uint32_t ret_ref = 0;
41436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41439         ret_ref = (uintptr_t)ret_var.inner;
41440         if (ret_var.is_owned) {
41441                 ret_ref |= 1;
41442         }
41443         return ret_ref;
41444 }
41445
41446 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
41447         LDKRouteHint o_conv;
41448         o_conv.inner = (void*)(o & (~1));
41449         o_conv.is_owned = false;
41450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41451         int64_t ret_conv = RouteHint_hash(&o_conv);
41452         return ret_conv;
41453 }
41454
41455 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
41456         LDKRouteHint a_conv;
41457         a_conv.inner = (void*)(a & (~1));
41458         a_conv.is_owned = false;
41459         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41460         LDKRouteHint b_conv;
41461         b_conv.inner = (void*)(b & (~1));
41462         b_conv.is_owned = false;
41463         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41464         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
41465         return ret_conv;
41466 }
41467
41468 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
41469         LDKRouteHint obj_conv;
41470         obj_conv.inner = (void*)(obj & (~1));
41471         obj_conv.is_owned = false;
41472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41473         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
41474         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41475         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41476         CVec_u8Z_free(ret_var);
41477         return ret_arr;
41478 }
41479
41480 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
41481         LDKu8slice ser_ref;
41482         ser_ref.datalen = ser->arr_len;
41483         ser_ref.data = ser->elems;
41484         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
41485         *ret_conv = RouteHint_read(ser_ref);
41486         FREE(ser);
41487         return (uint32_t)ret_conv;
41488 }
41489
41490 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
41491         LDKRouteHintHop this_obj_conv;
41492         this_obj_conv.inner = (void*)(this_obj & (~1));
41493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41495         RouteHintHop_free(this_obj_conv);
41496 }
41497
41498 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
41499         LDKRouteHintHop this_ptr_conv;
41500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41501         this_ptr_conv.is_owned = false;
41502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41503         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41504         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
41505         return ret_arr;
41506 }
41507
41508 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
41509         LDKRouteHintHop this_ptr_conv;
41510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41511         this_ptr_conv.is_owned = false;
41512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41513         LDKPublicKey val_ref;
41514         CHECK(val->arr_len == 33);
41515         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41516         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
41517 }
41518
41519 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
41520         LDKRouteHintHop this_ptr_conv;
41521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41522         this_ptr_conv.is_owned = false;
41523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41524         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
41525         return ret_conv;
41526 }
41527
41528 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
41529         LDKRouteHintHop this_ptr_conv;
41530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41531         this_ptr_conv.is_owned = false;
41532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41533         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
41534 }
41535
41536 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
41537         LDKRouteHintHop this_ptr_conv;
41538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41539         this_ptr_conv.is_owned = false;
41540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41541         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
41542         uint32_t ret_ref = 0;
41543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41546         ret_ref = (uintptr_t)ret_var.inner;
41547         if (ret_var.is_owned) {
41548                 ret_ref |= 1;
41549         }
41550         return ret_ref;
41551 }
41552
41553 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
41554         LDKRouteHintHop this_ptr_conv;
41555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41556         this_ptr_conv.is_owned = false;
41557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41558         LDKRoutingFees val_conv;
41559         val_conv.inner = (void*)(val & (~1));
41560         val_conv.is_owned = (val & 1) || (val == 0);
41561         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41562         val_conv = RoutingFees_clone(&val_conv);
41563         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
41564 }
41565
41566 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
41567         LDKRouteHintHop this_ptr_conv;
41568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41569         this_ptr_conv.is_owned = false;
41570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41571         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
41572         return ret_conv;
41573 }
41574
41575 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
41576         LDKRouteHintHop this_ptr_conv;
41577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41578         this_ptr_conv.is_owned = false;
41579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41580         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41581 }
41582
41583 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
41584         LDKRouteHintHop this_ptr_conv;
41585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41586         this_ptr_conv.is_owned = false;
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41588         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41589         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
41590         uint32_t ret_ref = (uintptr_t)ret_copy;
41591         return ret_ref;
41592 }
41593
41594 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
41595         LDKRouteHintHop this_ptr_conv;
41596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41597         this_ptr_conv.is_owned = false;
41598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41599         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41600         CHECK_ACCESS(val_ptr);
41601         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41602         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41603         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
41604 }
41605
41606 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
41607         LDKRouteHintHop this_ptr_conv;
41608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41609         this_ptr_conv.is_owned = false;
41610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41611         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41612         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
41613         uint32_t ret_ref = (uintptr_t)ret_copy;
41614         return ret_ref;
41615 }
41616
41617 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
41618         LDKRouteHintHop this_ptr_conv;
41619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41620         this_ptr_conv.is_owned = false;
41621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41622         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41623         CHECK_ACCESS(val_ptr);
41624         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41625         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41626         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
41627 }
41628
41629 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) {
41630         LDKPublicKey src_node_id_arg_ref;
41631         CHECK(src_node_id_arg->arr_len == 33);
41632         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
41633         LDKRoutingFees fees_arg_conv;
41634         fees_arg_conv.inner = (void*)(fees_arg & (~1));
41635         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
41636         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
41637         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
41638         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
41639         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
41640         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
41641         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
41642         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
41643         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
41644         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
41645         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
41646         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);
41647         uint32_t ret_ref = 0;
41648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41651         ret_ref = (uintptr_t)ret_var.inner;
41652         if (ret_var.is_owned) {
41653                 ret_ref |= 1;
41654         }
41655         return ret_ref;
41656 }
41657
41658 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
41659         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
41660 uint32_t ret_ref = 0;
41661 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41662 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41663 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41664 ret_ref = (uintptr_t)ret_var.inner;
41665 if (ret_var.is_owned) {
41666         ret_ref |= 1;
41667 }
41668         return ret_ref;
41669 }
41670 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
41671         LDKRouteHintHop arg_conv;
41672         arg_conv.inner = (void*)(arg & (~1));
41673         arg_conv.is_owned = false;
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41675         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
41676         return ret_conv;
41677 }
41678
41679 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
41680         LDKRouteHintHop orig_conv;
41681         orig_conv.inner = (void*)(orig & (~1));
41682         orig_conv.is_owned = false;
41683         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41684         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
41685         uint32_t ret_ref = 0;
41686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41689         ret_ref = (uintptr_t)ret_var.inner;
41690         if (ret_var.is_owned) {
41691                 ret_ref |= 1;
41692         }
41693         return ret_ref;
41694 }
41695
41696 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
41697         LDKRouteHintHop o_conv;
41698         o_conv.inner = (void*)(o & (~1));
41699         o_conv.is_owned = false;
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41701         int64_t ret_conv = RouteHintHop_hash(&o_conv);
41702         return ret_conv;
41703 }
41704
41705 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
41706         LDKRouteHintHop a_conv;
41707         a_conv.inner = (void*)(a & (~1));
41708         a_conv.is_owned = false;
41709         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41710         LDKRouteHintHop b_conv;
41711         b_conv.inner = (void*)(b & (~1));
41712         b_conv.is_owned = false;
41713         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41714         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
41715         return ret_conv;
41716 }
41717
41718 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
41719         LDKRouteHintHop obj_conv;
41720         obj_conv.inner = (void*)(obj & (~1));
41721         obj_conv.is_owned = false;
41722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41723         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
41724         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41725         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41726         CVec_u8Z_free(ret_var);
41727         return ret_arr;
41728 }
41729
41730 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
41731         LDKu8slice ser_ref;
41732         ser_ref.datalen = ser->arr_len;
41733         ser_ref.data = ser->elems;
41734         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
41735         *ret_conv = RouteHintHop_read(ser_ref);
41736         FREE(ser);
41737         return (uint32_t)ret_conv;
41738 }
41739
41740 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) {
41741         LDKPublicKey our_node_pubkey_ref;
41742         CHECK(our_node_pubkey->arr_len == 33);
41743         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41744         LDKRouteParameters route_params_conv;
41745         route_params_conv.inner = (void*)(route_params & (~1));
41746         route_params_conv.is_owned = false;
41747         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41748         LDKNetworkGraph network_graph_conv;
41749         network_graph_conv.inner = (void*)(network_graph & (~1));
41750         network_graph_conv.is_owned = false;
41751         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41752         LDKCVec_ChannelDetailsZ first_hops_constr;
41753         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
41754         if (first_hops != 0) {
41755                 first_hops_constr.datalen = first_hops->arr_len;
41756                 if (first_hops_constr.datalen > 0)
41757                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
41758                 else
41759                         first_hops_constr.data = NULL;
41760                 uint32_t* first_hops_vals = first_hops->elems;
41761                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
41762                         uint32_t first_hops_conv_16 = first_hops_vals[q];
41763                         LDKChannelDetails first_hops_conv_16_conv;
41764                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
41765                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
41766                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
41767                         first_hops_constr.data[q] = first_hops_conv_16_conv;
41768                 }
41769                 FREE(first_hops);
41770                 first_hops_ptr = &first_hops_constr;
41771         }
41772         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41773         CHECK_ACCESS(logger_ptr);
41774         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41775         if (logger_conv.free == LDKLogger_JCalls_free) {
41776                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41777                 LDKLogger_JCalls_cloned(&logger_conv);
41778         }
41779         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
41780         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
41781         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
41782         unsigned char random_seed_bytes_arr[32];
41783         CHECK(random_seed_bytes->arr_len == 32);
41784         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41785         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41786         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41787         *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);
41788         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
41789         return (uint32_t)ret_conv;
41790 }
41791
41792 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) {
41793         LDKPublicKey our_node_pubkey_ref;
41794         CHECK(our_node_pubkey->arr_len == 33);
41795         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41796         LDKCVec_PublicKeyZ hops_constr;
41797         hops_constr.datalen = hops->arr_len;
41798         if (hops_constr.datalen > 0)
41799                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
41800         else
41801                 hops_constr.data = NULL;
41802         int8_tArray* hops_vals = (void*) hops->elems;
41803         for (size_t m = 0; m < hops_constr.datalen; m++) {
41804                 int8_tArray hops_conv_12 = hops_vals[m];
41805                 LDKPublicKey hops_conv_12_ref;
41806                 CHECK(hops_conv_12->arr_len == 33);
41807                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
41808                 hops_constr.data[m] = hops_conv_12_ref;
41809         }
41810         FREE(hops);
41811         LDKRouteParameters route_params_conv;
41812         route_params_conv.inner = (void*)(route_params & (~1));
41813         route_params_conv.is_owned = false;
41814         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41815         LDKNetworkGraph network_graph_conv;
41816         network_graph_conv.inner = (void*)(network_graph & (~1));
41817         network_graph_conv.is_owned = false;
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41819         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41820         CHECK_ACCESS(logger_ptr);
41821         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41822         if (logger_conv.free == LDKLogger_JCalls_free) {
41823                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41824                 LDKLogger_JCalls_cloned(&logger_conv);
41825         }
41826         unsigned char random_seed_bytes_arr[32];
41827         CHECK(random_seed_bytes->arr_len == 32);
41828         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41829         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41830         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41831         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
41832         return (uint32_t)ret_conv;
41833 }
41834
41835 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
41836         if ((this_ptr & 1) != 0) return;
41837         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41838         CHECK_ACCESS(this_ptr_ptr);
41839         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
41840         FREE((void*)this_ptr);
41841         Score_free(this_ptr_conv);
41842 }
41843
41844 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
41845         if ((this_ptr & 1) != 0) return;
41846         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41847         CHECK_ACCESS(this_ptr_ptr);
41848         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
41849         FREE((void*)this_ptr);
41850         LockableScore_free(this_ptr_conv);
41851 }
41852
41853 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
41854         LDKMultiThreadedLockableScore this_obj_conv;
41855         this_obj_conv.inner = (void*)(this_obj & (~1));
41856         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41858         MultiThreadedLockableScore_free(this_obj_conv);
41859 }
41860
41861 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
41862         LDKMultiThreadedLockableScore obj_conv;
41863         obj_conv.inner = (void*)(obj & (~1));
41864         obj_conv.is_owned = false;
41865         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41866         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
41867         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41868         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41869         CVec_u8Z_free(ret_var);
41870         return ret_arr;
41871 }
41872
41873 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
41874         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
41875         CHECK_ACCESS(score_ptr);
41876         LDKScore score_conv = *(LDKScore*)(score_ptr);
41877         if (score_conv.free == LDKScore_JCalls_free) {
41878                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41879                 LDKScore_JCalls_cloned(&score_conv);
41880         }
41881         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
41882         uint32_t ret_ref = 0;
41883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41886         ret_ref = (uintptr_t)ret_var.inner;
41887         if (ret_var.is_owned) {
41888                 ret_ref |= 1;
41889         }
41890         return ret_ref;
41891 }
41892
41893 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
41894         LDKChannelUsage this_obj_conv;
41895         this_obj_conv.inner = (void*)(this_obj & (~1));
41896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41898         ChannelUsage_free(this_obj_conv);
41899 }
41900
41901 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
41902         LDKChannelUsage this_ptr_conv;
41903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41904         this_ptr_conv.is_owned = false;
41905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41906         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
41907         return ret_conv;
41908 }
41909
41910 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
41911         LDKChannelUsage this_ptr_conv;
41912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41913         this_ptr_conv.is_owned = false;
41914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41915         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
41916 }
41917
41918 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
41919         LDKChannelUsage this_ptr_conv;
41920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41921         this_ptr_conv.is_owned = false;
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41923         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
41924         return ret_conv;
41925 }
41926
41927 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
41928         LDKChannelUsage this_ptr_conv;
41929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41930         this_ptr_conv.is_owned = false;
41931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41932         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
41933 }
41934
41935 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
41936         LDKChannelUsage this_ptr_conv;
41937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41938         this_ptr_conv.is_owned = false;
41939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41940         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
41941         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
41942         uint32_t ret_ref = (uintptr_t)ret_copy;
41943         return ret_ref;
41944 }
41945
41946 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
41947         LDKChannelUsage this_ptr_conv;
41948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41949         this_ptr_conv.is_owned = false;
41950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41951         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41952         CHECK_ACCESS(val_ptr);
41953         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
41954         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
41955         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
41956 }
41957
41958 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) {
41959         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
41960         CHECK_ACCESS(effective_capacity_arg_ptr);
41961         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
41962         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
41963         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
41964         uint32_t ret_ref = 0;
41965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41968         ret_ref = (uintptr_t)ret_var.inner;
41969         if (ret_var.is_owned) {
41970                 ret_ref |= 1;
41971         }
41972         return ret_ref;
41973 }
41974
41975 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
41976         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
41977 uint32_t ret_ref = 0;
41978 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41979 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41980 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41981 ret_ref = (uintptr_t)ret_var.inner;
41982 if (ret_var.is_owned) {
41983         ret_ref |= 1;
41984 }
41985         return ret_ref;
41986 }
41987 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
41988         LDKChannelUsage arg_conv;
41989         arg_conv.inner = (void*)(arg & (~1));
41990         arg_conv.is_owned = false;
41991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41992         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
41993         return ret_conv;
41994 }
41995
41996 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
41997         LDKChannelUsage orig_conv;
41998         orig_conv.inner = (void*)(orig & (~1));
41999         orig_conv.is_owned = false;
42000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42001         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
42002         uint32_t ret_ref = 0;
42003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42006         ret_ref = (uintptr_t)ret_var.inner;
42007         if (ret_var.is_owned) {
42008                 ret_ref |= 1;
42009         }
42010         return ret_ref;
42011 }
42012
42013 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
42014         LDKFixedPenaltyScorer this_obj_conv;
42015         this_obj_conv.inner = (void*)(this_obj & (~1));
42016         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42018         FixedPenaltyScorer_free(this_obj_conv);
42019 }
42020
42021 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42022         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42023 uint32_t ret_ref = 0;
42024 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42025 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42026 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42027 ret_ref = (uintptr_t)ret_var.inner;
42028 if (ret_var.is_owned) {
42029         ret_ref |= 1;
42030 }
42031         return ret_ref;
42032 }
42033 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
42034         LDKFixedPenaltyScorer arg_conv;
42035         arg_conv.inner = (void*)(arg & (~1));
42036         arg_conv.is_owned = false;
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42038         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42039         return ret_conv;
42040 }
42041
42042 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
42043         LDKFixedPenaltyScorer orig_conv;
42044         orig_conv.inner = (void*)(orig & (~1));
42045         orig_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42047         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42048         uint32_t ret_ref = 0;
42049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42052         ret_ref = (uintptr_t)ret_var.inner;
42053         if (ret_var.is_owned) {
42054                 ret_ref |= 1;
42055         }
42056         return ret_ref;
42057 }
42058
42059 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
42060         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42061         uint32_t ret_ref = 0;
42062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42065         ret_ref = (uintptr_t)ret_var.inner;
42066         if (ret_var.is_owned) {
42067                 ret_ref |= 1;
42068         }
42069         return ret_ref;
42070 }
42071
42072 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
42073         LDKFixedPenaltyScorer this_arg_conv;
42074         this_arg_conv.inner = (void*)(this_arg & (~1));
42075         this_arg_conv.is_owned = false;
42076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42077         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42078         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42079         return (uint32_t)ret_ret;
42080 }
42081
42082 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
42083         LDKFixedPenaltyScorer obj_conv;
42084         obj_conv.inner = (void*)(obj & (~1));
42085         obj_conv.is_owned = false;
42086         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42087         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42088         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42089         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42090         CVec_u8Z_free(ret_var);
42091         return ret_arr;
42092 }
42093
42094 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
42095         LDKu8slice ser_ref;
42096         ser_ref.datalen = ser->arr_len;
42097         ser_ref.data = ser->elems;
42098         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42099         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
42100         FREE(ser);
42101         return (uint32_t)ret_conv;
42102 }
42103
42104 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
42105         LDKProbabilisticScorer this_obj_conv;
42106         this_obj_conv.inner = (void*)(this_obj & (~1));
42107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42109         ProbabilisticScorer_free(this_obj_conv);
42110 }
42111
42112 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
42113         LDKProbabilisticScoringParameters this_obj_conv;
42114         this_obj_conv.inner = (void*)(this_obj & (~1));
42115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42117         ProbabilisticScoringParameters_free(this_obj_conv);
42118 }
42119
42120 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
42121         LDKProbabilisticScoringParameters this_ptr_conv;
42122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42123         this_ptr_conv.is_owned = false;
42124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42125         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42126         return ret_conv;
42127 }
42128
42129 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
42130         LDKProbabilisticScoringParameters this_ptr_conv;
42131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42132         this_ptr_conv.is_owned = false;
42133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42134         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42135 }
42136
42137 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
42138         LDKProbabilisticScoringParameters this_ptr_conv;
42139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42140         this_ptr_conv.is_owned = false;
42141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42142         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
42143         return ret_conv;
42144 }
42145
42146 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) {
42147         LDKProbabilisticScoringParameters this_ptr_conv;
42148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42149         this_ptr_conv.is_owned = false;
42150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42151         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
42152 }
42153
42154 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
42155         LDKProbabilisticScoringParameters this_ptr_conv;
42156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42157         this_ptr_conv.is_owned = false;
42158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42159         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
42160         return ret_conv;
42161 }
42162
42163 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) {
42164         LDKProbabilisticScoringParameters this_ptr_conv;
42165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42166         this_ptr_conv.is_owned = false;
42167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42168         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
42169 }
42170
42171 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
42172         LDKProbabilisticScoringParameters this_ptr_conv;
42173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42174         this_ptr_conv.is_owned = false;
42175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42176         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
42177         return ret_conv;
42178 }
42179
42180 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(uint32_t this_ptr, int64_t val) {
42181         LDKProbabilisticScoringParameters this_ptr_conv;
42182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42183         this_ptr_conv.is_owned = false;
42184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42185         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
42186 }
42187
42188 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint32_t this_ptr) {
42189         LDKProbabilisticScoringParameters this_ptr_conv;
42190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42191         this_ptr_conv.is_owned = false;
42192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42193         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
42194         return ret_conv;
42195 }
42196
42197 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) {
42198         LDKProbabilisticScoringParameters this_ptr_conv;
42199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42200         this_ptr_conv.is_owned = false;
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42202         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
42203 }
42204
42205 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
42206         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
42207 uint32_t ret_ref = 0;
42208 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42209 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42210 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42211 ret_ref = (uintptr_t)ret_var.inner;
42212 if (ret_var.is_owned) {
42213         ret_ref |= 1;
42214 }
42215         return ret_ref;
42216 }
42217 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
42218         LDKProbabilisticScoringParameters arg_conv;
42219         arg_conv.inner = (void*)(arg & (~1));
42220         arg_conv.is_owned = false;
42221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42222         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
42223         return ret_conv;
42224 }
42225
42226 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
42227         LDKProbabilisticScoringParameters orig_conv;
42228         orig_conv.inner = (void*)(orig & (~1));
42229         orig_conv.is_owned = false;
42230         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42231         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
42232         uint32_t ret_ref = 0;
42233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42236         ret_ref = (uintptr_t)ret_var.inner;
42237         if (ret_var.is_owned) {
42238                 ret_ref |= 1;
42239         }
42240         return ret_ref;
42241 }
42242
42243 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
42244         LDKProbabilisticScoringParameters params_conv;
42245         params_conv.inner = (void*)(params & (~1));
42246         params_conv.is_owned = (params & 1) || (params == 0);
42247         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
42248         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
42249         LDKNetworkGraph network_graph_conv;
42250         network_graph_conv.inner = (void*)(network_graph & (~1));
42251         network_graph_conv.is_owned = false;
42252         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42253         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42254         CHECK_ACCESS(logger_ptr);
42255         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42256         if (logger_conv.free == LDKLogger_JCalls_free) {
42257                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42258                 LDKLogger_JCalls_cloned(&logger_conv);
42259         }
42260         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
42261         uint32_t ret_ref = 0;
42262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42265         ret_ref = (uintptr_t)ret_var.inner;
42266         if (ret_var.is_owned) {
42267                 ret_ref |= 1;
42268         }
42269         return ret_ref;
42270 }
42271
42272 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
42273         LDKProbabilisticScorer this_arg_conv;
42274         this_arg_conv.inner = (void*)(this_arg & (~1));
42275         this_arg_conv.is_owned = false;
42276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42277         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
42278 }
42279
42280 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) {
42281         LDKProbabilisticScorer this_arg_conv;
42282         this_arg_conv.inner = (void*)(this_arg & (~1));
42283         this_arg_conv.is_owned = false;
42284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42285         LDKNodeId target_conv;
42286         target_conv.inner = (void*)(target & (~1));
42287         target_conv.is_owned = false;
42288         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
42289         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
42290         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
42291         uint32_t ret_ref = (uintptr_t)ret_copy;
42292         return ret_ref;
42293 }
42294
42295 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint32_t this_arg, uint32_t node_id) {
42296         LDKProbabilisticScorer this_arg_conv;
42297         this_arg_conv.inner = (void*)(this_arg & (~1));
42298         this_arg_conv.is_owned = false;
42299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42300         LDKNodeId node_id_conv;
42301         node_id_conv.inner = (void*)(node_id & (~1));
42302         node_id_conv.is_owned = false;
42303         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
42304         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
42305 }
42306
42307 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint32_t this_arg, uint32_t node_id) {
42308         LDKProbabilisticScorer this_arg_conv;
42309         this_arg_conv.inner = (void*)(this_arg & (~1));
42310         this_arg_conv.is_owned = false;
42311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42312         LDKNodeId node_id_conv;
42313         node_id_conv.inner = (void*)(node_id & (~1));
42314         node_id_conv.is_owned = false;
42315         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
42316         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
42317 }
42318
42319 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_banned"))) TS_ProbabilisticScorer_clear_banned(uint32_t this_arg) {
42320         LDKProbabilisticScorer this_arg_conv;
42321         this_arg_conv.inner = (void*)(this_arg & (~1));
42322         this_arg_conv.is_owned = false;
42323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42324         ProbabilisticScorer_clear_banned(&this_arg_conv);
42325 }
42326
42327 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint32_t this_arg, uint32_tArray node_ids) {
42328         LDKProbabilisticScoringParameters this_arg_conv;
42329         this_arg_conv.inner = (void*)(this_arg & (~1));
42330         this_arg_conv.is_owned = false;
42331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42332         LDKCVec_NodeIdZ node_ids_constr;
42333         node_ids_constr.datalen = node_ids->arr_len;
42334         if (node_ids_constr.datalen > 0)
42335                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
42336         else
42337                 node_ids_constr.data = NULL;
42338         uint32_t* node_ids_vals = node_ids->elems;
42339         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
42340                 uint32_t node_ids_conv_8 = node_ids_vals[i];
42341                 LDKNodeId node_ids_conv_8_conv;
42342                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
42343                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
42344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
42345                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
42346                 node_ids_constr.data[i] = node_ids_conv_8_conv;
42347         }
42348         FREE(node_ids);
42349         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
42350 }
42351
42352 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
42353         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
42354         uint32_t ret_ref = 0;
42355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42358         ret_ref = (uintptr_t)ret_var.inner;
42359         if (ret_var.is_owned) {
42360                 ret_ref |= 1;
42361         }
42362         return ret_ref;
42363 }
42364
42365 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
42366         LDKProbabilisticScorer this_arg_conv;
42367         this_arg_conv.inner = (void*)(this_arg & (~1));
42368         this_arg_conv.is_owned = false;
42369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42370         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42371         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
42372         return (uint32_t)ret_ret;
42373 }
42374
42375 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
42376         LDKProbabilisticScorer obj_conv;
42377         obj_conv.inner = (void*)(obj & (~1));
42378         obj_conv.is_owned = false;
42379         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42380         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
42381         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42382         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42383         CVec_u8Z_free(ret_var);
42384         return ret_arr;
42385 }
42386
42387 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) {
42388         LDKu8slice ser_ref;
42389         ser_ref.datalen = ser->arr_len;
42390         ser_ref.data = ser->elems;
42391         LDKProbabilisticScoringParameters arg_a_conv;
42392         arg_a_conv.inner = (void*)(arg_a & (~1));
42393         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
42394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
42395         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
42396         LDKNetworkGraph arg_b_conv;
42397         arg_b_conv.inner = (void*)(arg_b & (~1));
42398         arg_b_conv.is_owned = false;
42399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
42400         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
42401         CHECK_ACCESS(arg_c_ptr);
42402         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
42403         if (arg_c_conv.free == LDKLogger_JCalls_free) {
42404                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42405                 LDKLogger_JCalls_cloned(&arg_c_conv);
42406         }
42407         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
42408         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
42409         FREE(ser);
42410         return (uint32_t)ret_conv;
42411 }
42412
42413 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
42414         if ((this_ptr & 1) != 0) return;
42415         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42416         CHECK_ACCESS(this_ptr_ptr);
42417         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
42418         FREE((void*)this_ptr);
42419         ParseError_free(this_ptr_conv);
42420 }
42421
42422 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
42423         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42424         *ret_copy = ParseError_clone(arg);
42425 uint32_t ret_ref = (uintptr_t)ret_copy;
42426         return ret_ref;
42427 }
42428 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
42429         LDKParseError* arg_conv = (LDKParseError*)arg;
42430         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
42431         return ret_conv;
42432 }
42433
42434 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
42435         LDKParseError* orig_conv = (LDKParseError*)orig;
42436         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42437         *ret_copy = ParseError_clone(orig_conv);
42438         uint32_t ret_ref = (uintptr_t)ret_copy;
42439         return ret_ref;
42440 }
42441
42442 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
42443         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
42444         CHECK_ACCESS(a_ptr);
42445         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
42446         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
42447         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42448         *ret_copy = ParseError_bech32_error(a_conv);
42449         uint32_t ret_ref = (uintptr_t)ret_copy;
42450         return ret_ref;
42451 }
42452
42453 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
42454         
42455         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42456         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
42457         uint32_t ret_ref = (uintptr_t)ret_copy;
42458         return ret_ref;
42459 }
42460
42461 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
42462         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
42463         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42464         *ret_copy = ParseError_malformed_signature(a_conv);
42465         uint32_t ret_ref = (uintptr_t)ret_copy;
42466         return ret_ref;
42467 }
42468
42469 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
42470         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42471         *ret_copy = ParseError_bad_prefix();
42472         uint32_t ret_ref = (uintptr_t)ret_copy;
42473         return ret_ref;
42474 }
42475
42476 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
42477         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42478         *ret_copy = ParseError_unknown_currency();
42479         uint32_t ret_ref = (uintptr_t)ret_copy;
42480         return ret_ref;
42481 }
42482
42483 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
42484         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42485         *ret_copy = ParseError_unknown_si_prefix();
42486         uint32_t ret_ref = (uintptr_t)ret_copy;
42487         return ret_ref;
42488 }
42489
42490 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
42491         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42492         *ret_copy = ParseError_malformed_hrp();
42493         uint32_t ret_ref = (uintptr_t)ret_copy;
42494         return ret_ref;
42495 }
42496
42497 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
42498         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42499         *ret_copy = ParseError_too_short_data_part();
42500         uint32_t ret_ref = (uintptr_t)ret_copy;
42501         return ret_ref;
42502 }
42503
42504 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
42505         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42506         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
42507         uint32_t ret_ref = (uintptr_t)ret_copy;
42508         return ret_ref;
42509 }
42510
42511 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
42512         
42513         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42514         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
42515         uint32_t ret_ref = (uintptr_t)ret_copy;
42516         return ret_ref;
42517 }
42518
42519 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
42520         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42521         *ret_copy = ParseError_padding_error();
42522         uint32_t ret_ref = (uintptr_t)ret_copy;
42523         return ret_ref;
42524 }
42525
42526 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
42527         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42528         *ret_copy = ParseError_integer_overflow_error();
42529         uint32_t ret_ref = (uintptr_t)ret_copy;
42530         return ret_ref;
42531 }
42532
42533 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
42534         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42535         *ret_copy = ParseError_invalid_seg_wit_program_length();
42536         uint32_t ret_ref = (uintptr_t)ret_copy;
42537         return ret_ref;
42538 }
42539
42540 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
42541         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42542         *ret_copy = ParseError_invalid_pub_key_hash_length();
42543         uint32_t ret_ref = (uintptr_t)ret_copy;
42544         return ret_ref;
42545 }
42546
42547 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
42548         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42549         *ret_copy = ParseError_invalid_script_hash_length();
42550         uint32_t ret_ref = (uintptr_t)ret_copy;
42551         return ret_ref;
42552 }
42553
42554 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
42555         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42556         *ret_copy = ParseError_invalid_recovery_id();
42557         uint32_t ret_ref = (uintptr_t)ret_copy;
42558         return ret_ref;
42559 }
42560
42561 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
42562         LDKStr a_conv = str_ref_to_owned_c(a);
42563         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42564         *ret_copy = ParseError_invalid_slice_length(a_conv);
42565         uint32_t ret_ref = (uintptr_t)ret_copy;
42566         return ret_ref;
42567 }
42568
42569 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
42570         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42571         *ret_copy = ParseError_skip();
42572         uint32_t ret_ref = (uintptr_t)ret_copy;
42573         return ret_ref;
42574 }
42575
42576 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
42577         if ((this_ptr & 1) != 0) return;
42578         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42579         CHECK_ACCESS(this_ptr_ptr);
42580         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
42581         FREE((void*)this_ptr);
42582         ParseOrSemanticError_free(this_ptr_conv);
42583 }
42584
42585 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
42586         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42587         *ret_copy = ParseOrSemanticError_clone(arg);
42588 uint32_t ret_ref = (uintptr_t)ret_copy;
42589         return ret_ref;
42590 }
42591 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
42592         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
42593         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
42594         return ret_conv;
42595 }
42596
42597 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
42598         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
42599         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42600         *ret_copy = ParseOrSemanticError_clone(orig_conv);
42601         uint32_t ret_ref = (uintptr_t)ret_copy;
42602         return ret_ref;
42603 }
42604
42605 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
42606         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
42607         CHECK_ACCESS(a_ptr);
42608         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
42609         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
42610         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42611         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
42612         uint32_t ret_ref = (uintptr_t)ret_copy;
42613         return ret_ref;
42614 }
42615
42616 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
42617         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
42618         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42619         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
42620         uint32_t ret_ref = (uintptr_t)ret_copy;
42621         return ret_ref;
42622 }
42623
42624 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
42625         LDKInvoice this_obj_conv;
42626         this_obj_conv.inner = (void*)(this_obj & (~1));
42627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42629         Invoice_free(this_obj_conv);
42630 }
42631
42632 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
42633         LDKInvoice a_conv;
42634         a_conv.inner = (void*)(a & (~1));
42635         a_conv.is_owned = false;
42636         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42637         LDKInvoice b_conv;
42638         b_conv.inner = (void*)(b & (~1));
42639         b_conv.is_owned = false;
42640         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42641         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
42642         return ret_conv;
42643 }
42644
42645 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
42646         LDKInvoice ret_var = Invoice_clone(arg);
42647 uint32_t ret_ref = 0;
42648 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42649 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42650 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42651 ret_ref = (uintptr_t)ret_var.inner;
42652 if (ret_var.is_owned) {
42653         ret_ref |= 1;
42654 }
42655         return ret_ref;
42656 }
42657 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
42658         LDKInvoice arg_conv;
42659         arg_conv.inner = (void*)(arg & (~1));
42660         arg_conv.is_owned = false;
42661         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42662         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
42663         return ret_conv;
42664 }
42665
42666 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
42667         LDKInvoice orig_conv;
42668         orig_conv.inner = (void*)(orig & (~1));
42669         orig_conv.is_owned = false;
42670         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42671         LDKInvoice ret_var = Invoice_clone(&orig_conv);
42672         uint32_t ret_ref = 0;
42673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42676         ret_ref = (uintptr_t)ret_var.inner;
42677         if (ret_var.is_owned) {
42678                 ret_ref |= 1;
42679         }
42680         return ret_ref;
42681 }
42682
42683 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
42684         LDKSignedRawInvoice this_obj_conv;
42685         this_obj_conv.inner = (void*)(this_obj & (~1));
42686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42688         SignedRawInvoice_free(this_obj_conv);
42689 }
42690
42691 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
42692         LDKSignedRawInvoice a_conv;
42693         a_conv.inner = (void*)(a & (~1));
42694         a_conv.is_owned = false;
42695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42696         LDKSignedRawInvoice b_conv;
42697         b_conv.inner = (void*)(b & (~1));
42698         b_conv.is_owned = false;
42699         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42700         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
42701         return ret_conv;
42702 }
42703
42704 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
42705         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
42706 uint32_t ret_ref = 0;
42707 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42708 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42709 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42710 ret_ref = (uintptr_t)ret_var.inner;
42711 if (ret_var.is_owned) {
42712         ret_ref |= 1;
42713 }
42714         return ret_ref;
42715 }
42716 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
42717         LDKSignedRawInvoice arg_conv;
42718         arg_conv.inner = (void*)(arg & (~1));
42719         arg_conv.is_owned = false;
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42721         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
42722         return ret_conv;
42723 }
42724
42725 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
42726         LDKSignedRawInvoice orig_conv;
42727         orig_conv.inner = (void*)(orig & (~1));
42728         orig_conv.is_owned = false;
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42730         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
42731         uint32_t ret_ref = 0;
42732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42735         ret_ref = (uintptr_t)ret_var.inner;
42736         if (ret_var.is_owned) {
42737                 ret_ref |= 1;
42738         }
42739         return ret_ref;
42740 }
42741
42742 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
42743         LDKRawInvoice this_obj_conv;
42744         this_obj_conv.inner = (void*)(this_obj & (~1));
42745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42747         RawInvoice_free(this_obj_conv);
42748 }
42749
42750 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
42751         LDKRawInvoice this_ptr_conv;
42752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42753         this_ptr_conv.is_owned = false;
42754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42755         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
42756         uint32_t ret_ref = 0;
42757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42760         ret_ref = (uintptr_t)ret_var.inner;
42761         if (ret_var.is_owned) {
42762                 ret_ref |= 1;
42763         }
42764         return ret_ref;
42765 }
42766
42767 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
42768         LDKRawInvoice this_ptr_conv;
42769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42770         this_ptr_conv.is_owned = false;
42771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42772         LDKRawDataPart val_conv;
42773         val_conv.inner = (void*)(val & (~1));
42774         val_conv.is_owned = (val & 1) || (val == 0);
42775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42776         val_conv = RawDataPart_clone(&val_conv);
42777         RawInvoice_set_data(&this_ptr_conv, val_conv);
42778 }
42779
42780 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
42781         LDKRawInvoice a_conv;
42782         a_conv.inner = (void*)(a & (~1));
42783         a_conv.is_owned = false;
42784         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42785         LDKRawInvoice b_conv;
42786         b_conv.inner = (void*)(b & (~1));
42787         b_conv.is_owned = false;
42788         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42789         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
42790         return ret_conv;
42791 }
42792
42793 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
42794         LDKRawInvoice ret_var = RawInvoice_clone(arg);
42795 uint32_t ret_ref = 0;
42796 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42797 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42799 ret_ref = (uintptr_t)ret_var.inner;
42800 if (ret_var.is_owned) {
42801         ret_ref |= 1;
42802 }
42803         return ret_ref;
42804 }
42805 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
42806         LDKRawInvoice arg_conv;
42807         arg_conv.inner = (void*)(arg & (~1));
42808         arg_conv.is_owned = false;
42809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42810         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
42811         return ret_conv;
42812 }
42813
42814 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
42815         LDKRawInvoice orig_conv;
42816         orig_conv.inner = (void*)(orig & (~1));
42817         orig_conv.is_owned = false;
42818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42819         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
42820         uint32_t ret_ref = 0;
42821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42824         ret_ref = (uintptr_t)ret_var.inner;
42825         if (ret_var.is_owned) {
42826                 ret_ref |= 1;
42827         }
42828         return ret_ref;
42829 }
42830
42831 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
42832         LDKRawDataPart this_obj_conv;
42833         this_obj_conv.inner = (void*)(this_obj & (~1));
42834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42836         RawDataPart_free(this_obj_conv);
42837 }
42838
42839 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
42840         LDKRawDataPart this_ptr_conv;
42841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42842         this_ptr_conv.is_owned = false;
42843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42844         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
42845         uint32_t ret_ref = 0;
42846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42849         ret_ref = (uintptr_t)ret_var.inner;
42850         if (ret_var.is_owned) {
42851                 ret_ref |= 1;
42852         }
42853         return ret_ref;
42854 }
42855
42856 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
42857         LDKRawDataPart this_ptr_conv;
42858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42859         this_ptr_conv.is_owned = false;
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42861         LDKPositiveTimestamp val_conv;
42862         val_conv.inner = (void*)(val & (~1));
42863         val_conv.is_owned = (val & 1) || (val == 0);
42864         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42865         val_conv = PositiveTimestamp_clone(&val_conv);
42866         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
42867 }
42868
42869 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
42870         LDKRawDataPart a_conv;
42871         a_conv.inner = (void*)(a & (~1));
42872         a_conv.is_owned = false;
42873         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42874         LDKRawDataPart b_conv;
42875         b_conv.inner = (void*)(b & (~1));
42876         b_conv.is_owned = false;
42877         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42878         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
42879         return ret_conv;
42880 }
42881
42882 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
42883         LDKRawDataPart ret_var = RawDataPart_clone(arg);
42884 uint32_t ret_ref = 0;
42885 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42886 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42887 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42888 ret_ref = (uintptr_t)ret_var.inner;
42889 if (ret_var.is_owned) {
42890         ret_ref |= 1;
42891 }
42892         return ret_ref;
42893 }
42894 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
42895         LDKRawDataPart arg_conv;
42896         arg_conv.inner = (void*)(arg & (~1));
42897         arg_conv.is_owned = false;
42898         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42899         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
42900         return ret_conv;
42901 }
42902
42903 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
42904         LDKRawDataPart orig_conv;
42905         orig_conv.inner = (void*)(orig & (~1));
42906         orig_conv.is_owned = false;
42907         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42908         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
42909         uint32_t ret_ref = 0;
42910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42913         ret_ref = (uintptr_t)ret_var.inner;
42914         if (ret_var.is_owned) {
42915                 ret_ref |= 1;
42916         }
42917         return ret_ref;
42918 }
42919
42920 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
42921         LDKPositiveTimestamp this_obj_conv;
42922         this_obj_conv.inner = (void*)(this_obj & (~1));
42923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42925         PositiveTimestamp_free(this_obj_conv);
42926 }
42927
42928 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
42929         LDKPositiveTimestamp a_conv;
42930         a_conv.inner = (void*)(a & (~1));
42931         a_conv.is_owned = false;
42932         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42933         LDKPositiveTimestamp b_conv;
42934         b_conv.inner = (void*)(b & (~1));
42935         b_conv.is_owned = false;
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42937         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
42938         return ret_conv;
42939 }
42940
42941 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
42942         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
42943 uint32_t ret_ref = 0;
42944 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42945 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42946 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42947 ret_ref = (uintptr_t)ret_var.inner;
42948 if (ret_var.is_owned) {
42949         ret_ref |= 1;
42950 }
42951         return ret_ref;
42952 }
42953 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
42954         LDKPositiveTimestamp arg_conv;
42955         arg_conv.inner = (void*)(arg & (~1));
42956         arg_conv.is_owned = false;
42957         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42958         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
42959         return ret_conv;
42960 }
42961
42962 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
42963         LDKPositiveTimestamp orig_conv;
42964         orig_conv.inner = (void*)(orig & (~1));
42965         orig_conv.is_owned = false;
42966         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42967         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
42968         uint32_t ret_ref = 0;
42969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42972         ret_ref = (uintptr_t)ret_var.inner;
42973         if (ret_var.is_owned) {
42974                 ret_ref |= 1;
42975         }
42976         return ret_ref;
42977 }
42978
42979 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
42980         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
42981         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
42982         return ret_conv;
42983 }
42984
42985 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
42986         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
42987         return ret_conv;
42988 }
42989
42990 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
42991         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
42992         return ret_conv;
42993 }
42994
42995 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
42996         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
42997         return ret_conv;
42998 }
42999
43000 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
43001         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
43002         return ret_conv;
43003 }
43004
43005 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
43006         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
43007         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
43008         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
43009         return ret_conv;
43010 }
43011
43012 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
43013         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
43014         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
43015         return ret_conv;
43016 }
43017
43018 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
43019         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
43020         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
43021         return ret_conv;
43022 }
43023
43024 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
43025         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
43026         return ret_conv;
43027 }
43028
43029 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
43030         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
43031         return ret_conv;
43032 }
43033
43034 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
43035         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
43036         return ret_conv;
43037 }
43038
43039 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
43040         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
43041         return ret_conv;
43042 }
43043
43044 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
43045         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
43046         return ret_conv;
43047 }
43048
43049 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
43050         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
43051         int64_t ret_conv = Currency_hash(o_conv);
43052         return ret_conv;
43053 }
43054
43055 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
43056         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
43057         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
43058         jboolean ret_conv = Currency_eq(a_conv, b_conv);
43059         return ret_conv;
43060 }
43061
43062 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
43063         LDKSha256 this_obj_conv;
43064         this_obj_conv.inner = (void*)(this_obj & (~1));
43065         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43067         Sha256_free(this_obj_conv);
43068 }
43069
43070 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
43071         LDKSha256 ret_var = Sha256_clone(arg);
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 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
43083         LDKSha256 arg_conv;
43084         arg_conv.inner = (void*)(arg & (~1));
43085         arg_conv.is_owned = false;
43086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43087         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
43088         return ret_conv;
43089 }
43090
43091 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
43092         LDKSha256 orig_conv;
43093         orig_conv.inner = (void*)(orig & (~1));
43094         orig_conv.is_owned = false;
43095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43096         LDKSha256 ret_var = Sha256_clone(&orig_conv);
43097         uint32_t ret_ref = 0;
43098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43101         ret_ref = (uintptr_t)ret_var.inner;
43102         if (ret_var.is_owned) {
43103                 ret_ref |= 1;
43104         }
43105         return ret_ref;
43106 }
43107
43108 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
43109         LDKSha256 o_conv;
43110         o_conv.inner = (void*)(o & (~1));
43111         o_conv.is_owned = false;
43112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43113         int64_t ret_conv = Sha256_hash(&o_conv);
43114         return ret_conv;
43115 }
43116
43117 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
43118         LDKSha256 a_conv;
43119         a_conv.inner = (void*)(a & (~1));
43120         a_conv.is_owned = false;
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43122         LDKSha256 b_conv;
43123         b_conv.inner = (void*)(b & (~1));
43124         b_conv.is_owned = false;
43125         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43126         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
43127         return ret_conv;
43128 }
43129
43130 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
43131         LDKDescription this_obj_conv;
43132         this_obj_conv.inner = (void*)(this_obj & (~1));
43133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43135         Description_free(this_obj_conv);
43136 }
43137
43138 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
43139         LDKDescription ret_var = Description_clone(arg);
43140 uint32_t ret_ref = 0;
43141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43144 ret_ref = (uintptr_t)ret_var.inner;
43145 if (ret_var.is_owned) {
43146         ret_ref |= 1;
43147 }
43148         return ret_ref;
43149 }
43150 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
43151         LDKDescription arg_conv;
43152         arg_conv.inner = (void*)(arg & (~1));
43153         arg_conv.is_owned = false;
43154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43155         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
43156         return ret_conv;
43157 }
43158
43159 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
43160         LDKDescription orig_conv;
43161         orig_conv.inner = (void*)(orig & (~1));
43162         orig_conv.is_owned = false;
43163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43164         LDKDescription ret_var = Description_clone(&orig_conv);
43165         uint32_t ret_ref = 0;
43166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43169         ret_ref = (uintptr_t)ret_var.inner;
43170         if (ret_var.is_owned) {
43171                 ret_ref |= 1;
43172         }
43173         return ret_ref;
43174 }
43175
43176 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
43177         LDKDescription o_conv;
43178         o_conv.inner = (void*)(o & (~1));
43179         o_conv.is_owned = false;
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43181         int64_t ret_conv = Description_hash(&o_conv);
43182         return ret_conv;
43183 }
43184
43185 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
43186         LDKDescription a_conv;
43187         a_conv.inner = (void*)(a & (~1));
43188         a_conv.is_owned = false;
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43190         LDKDescription b_conv;
43191         b_conv.inner = (void*)(b & (~1));
43192         b_conv.is_owned = false;
43193         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43194         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
43195         return ret_conv;
43196 }
43197
43198 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
43199         LDKPayeePubKey this_obj_conv;
43200         this_obj_conv.inner = (void*)(this_obj & (~1));
43201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43203         PayeePubKey_free(this_obj_conv);
43204 }
43205
43206 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
43207         LDKPayeePubKey this_ptr_conv;
43208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43209         this_ptr_conv.is_owned = false;
43210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43211         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
43212         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
43213         return ret_arr;
43214 }
43215
43216 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
43217         LDKPayeePubKey this_ptr_conv;
43218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43219         this_ptr_conv.is_owned = false;
43220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43221         LDKPublicKey val_ref;
43222         CHECK(val->arr_len == 33);
43223         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
43224         PayeePubKey_set_a(&this_ptr_conv, val_ref);
43225 }
43226
43227 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
43228         LDKPublicKey a_arg_ref;
43229         CHECK(a_arg->arr_len == 33);
43230         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
43231         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
43232         uint32_t ret_ref = 0;
43233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43236         ret_ref = (uintptr_t)ret_var.inner;
43237         if (ret_var.is_owned) {
43238                 ret_ref |= 1;
43239         }
43240         return ret_ref;
43241 }
43242
43243 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
43244         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
43245 uint32_t ret_ref = 0;
43246 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43247 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43248 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43249 ret_ref = (uintptr_t)ret_var.inner;
43250 if (ret_var.is_owned) {
43251         ret_ref |= 1;
43252 }
43253         return ret_ref;
43254 }
43255 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
43256         LDKPayeePubKey arg_conv;
43257         arg_conv.inner = (void*)(arg & (~1));
43258         arg_conv.is_owned = false;
43259         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43260         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
43261         return ret_conv;
43262 }
43263
43264 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
43265         LDKPayeePubKey orig_conv;
43266         orig_conv.inner = (void*)(orig & (~1));
43267         orig_conv.is_owned = false;
43268         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43269         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
43270         uint32_t ret_ref = 0;
43271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43274         ret_ref = (uintptr_t)ret_var.inner;
43275         if (ret_var.is_owned) {
43276                 ret_ref |= 1;
43277         }
43278         return ret_ref;
43279 }
43280
43281 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
43282         LDKPayeePubKey o_conv;
43283         o_conv.inner = (void*)(o & (~1));
43284         o_conv.is_owned = false;
43285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43286         int64_t ret_conv = PayeePubKey_hash(&o_conv);
43287         return ret_conv;
43288 }
43289
43290 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
43291         LDKPayeePubKey a_conv;
43292         a_conv.inner = (void*)(a & (~1));
43293         a_conv.is_owned = false;
43294         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43295         LDKPayeePubKey b_conv;
43296         b_conv.inner = (void*)(b & (~1));
43297         b_conv.is_owned = false;
43298         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43299         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
43300         return ret_conv;
43301 }
43302
43303 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
43304         LDKExpiryTime this_obj_conv;
43305         this_obj_conv.inner = (void*)(this_obj & (~1));
43306         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43308         ExpiryTime_free(this_obj_conv);
43309 }
43310
43311 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
43312         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
43313 uint32_t ret_ref = 0;
43314 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43315 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43316 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43317 ret_ref = (uintptr_t)ret_var.inner;
43318 if (ret_var.is_owned) {
43319         ret_ref |= 1;
43320 }
43321         return ret_ref;
43322 }
43323 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
43324         LDKExpiryTime arg_conv;
43325         arg_conv.inner = (void*)(arg & (~1));
43326         arg_conv.is_owned = false;
43327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43328         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
43329         return ret_conv;
43330 }
43331
43332 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
43333         LDKExpiryTime orig_conv;
43334         orig_conv.inner = (void*)(orig & (~1));
43335         orig_conv.is_owned = false;
43336         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43337         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
43338         uint32_t ret_ref = 0;
43339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43342         ret_ref = (uintptr_t)ret_var.inner;
43343         if (ret_var.is_owned) {
43344                 ret_ref |= 1;
43345         }
43346         return ret_ref;
43347 }
43348
43349 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
43350         LDKExpiryTime o_conv;
43351         o_conv.inner = (void*)(o & (~1));
43352         o_conv.is_owned = false;
43353         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43354         int64_t ret_conv = ExpiryTime_hash(&o_conv);
43355         return ret_conv;
43356 }
43357
43358 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
43359         LDKExpiryTime a_conv;
43360         a_conv.inner = (void*)(a & (~1));
43361         a_conv.is_owned = false;
43362         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43363         LDKExpiryTime b_conv;
43364         b_conv.inner = (void*)(b & (~1));
43365         b_conv.is_owned = false;
43366         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43367         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
43368         return ret_conv;
43369 }
43370
43371 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
43372         LDKMinFinalCltvExpiry this_obj_conv;
43373         this_obj_conv.inner = (void*)(this_obj & (~1));
43374         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43376         MinFinalCltvExpiry_free(this_obj_conv);
43377 }
43378
43379 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
43380         LDKMinFinalCltvExpiry this_ptr_conv;
43381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43382         this_ptr_conv.is_owned = false;
43383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43384         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
43385         return ret_conv;
43386 }
43387
43388 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
43389         LDKMinFinalCltvExpiry this_ptr_conv;
43390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43391         this_ptr_conv.is_owned = false;
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43393         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
43394 }
43395
43396 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
43397         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
43398         uint32_t ret_ref = 0;
43399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43402         ret_ref = (uintptr_t)ret_var.inner;
43403         if (ret_var.is_owned) {
43404                 ret_ref |= 1;
43405         }
43406         return ret_ref;
43407 }
43408
43409 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
43410         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
43411 uint32_t ret_ref = 0;
43412 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43413 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43414 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43415 ret_ref = (uintptr_t)ret_var.inner;
43416 if (ret_var.is_owned) {
43417         ret_ref |= 1;
43418 }
43419         return ret_ref;
43420 }
43421 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
43422         LDKMinFinalCltvExpiry arg_conv;
43423         arg_conv.inner = (void*)(arg & (~1));
43424         arg_conv.is_owned = false;
43425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43426         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
43427         return ret_conv;
43428 }
43429
43430 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
43431         LDKMinFinalCltvExpiry orig_conv;
43432         orig_conv.inner = (void*)(orig & (~1));
43433         orig_conv.is_owned = false;
43434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43435         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
43436         uint32_t ret_ref = 0;
43437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43440         ret_ref = (uintptr_t)ret_var.inner;
43441         if (ret_var.is_owned) {
43442                 ret_ref |= 1;
43443         }
43444         return ret_ref;
43445 }
43446
43447 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
43448         LDKMinFinalCltvExpiry o_conv;
43449         o_conv.inner = (void*)(o & (~1));
43450         o_conv.is_owned = false;
43451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43452         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
43453         return ret_conv;
43454 }
43455
43456 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
43457         LDKMinFinalCltvExpiry a_conv;
43458         a_conv.inner = (void*)(a & (~1));
43459         a_conv.is_owned = false;
43460         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43461         LDKMinFinalCltvExpiry b_conv;
43462         b_conv.inner = (void*)(b & (~1));
43463         b_conv.is_owned = false;
43464         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43465         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
43466         return ret_conv;
43467 }
43468
43469 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
43470         if ((this_ptr & 1) != 0) return;
43471         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43472         CHECK_ACCESS(this_ptr_ptr);
43473         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
43474         FREE((void*)this_ptr);
43475         Fallback_free(this_ptr_conv);
43476 }
43477
43478 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
43479         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43480         *ret_copy = Fallback_clone(arg);
43481 uint32_t ret_ref = (uintptr_t)ret_copy;
43482         return ret_ref;
43483 }
43484 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
43485         LDKFallback* arg_conv = (LDKFallback*)arg;
43486         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
43487         return ret_conv;
43488 }
43489
43490 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
43491         LDKFallback* orig_conv = (LDKFallback*)orig;
43492         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43493         *ret_copy = Fallback_clone(orig_conv);
43494         uint32_t ret_ref = (uintptr_t)ret_copy;
43495         return ret_ref;
43496 }
43497
43498 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
43499         
43500         LDKCVec_u8Z program_ref;
43501         program_ref.datalen = program->arr_len;
43502         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
43503         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
43504         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43505         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
43506         uint32_t ret_ref = (uintptr_t)ret_copy;
43507         return ret_ref;
43508 }
43509
43510 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
43511         LDKTwentyBytes a_ref;
43512         CHECK(a->arr_len == 20);
43513         memcpy(a_ref.data, a->elems, 20); FREE(a);
43514         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43515         *ret_copy = Fallback_pub_key_hash(a_ref);
43516         uint32_t ret_ref = (uintptr_t)ret_copy;
43517         return ret_ref;
43518 }
43519
43520 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
43521         LDKTwentyBytes a_ref;
43522         CHECK(a->arr_len == 20);
43523         memcpy(a_ref.data, a->elems, 20); FREE(a);
43524         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43525         *ret_copy = Fallback_script_hash(a_ref);
43526         uint32_t ret_ref = (uintptr_t)ret_copy;
43527         return ret_ref;
43528 }
43529
43530 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
43531         LDKFallback* o_conv = (LDKFallback*)o;
43532         int64_t ret_conv = Fallback_hash(o_conv);
43533         return ret_conv;
43534 }
43535
43536 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
43537         LDKFallback* a_conv = (LDKFallback*)a;
43538         LDKFallback* b_conv = (LDKFallback*)b;
43539         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
43540         return ret_conv;
43541 }
43542
43543 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
43544         LDKInvoiceSignature this_obj_conv;
43545         this_obj_conv.inner = (void*)(this_obj & (~1));
43546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43548         InvoiceSignature_free(this_obj_conv);
43549 }
43550
43551 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
43552         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
43553 uint32_t ret_ref = 0;
43554 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43555 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43556 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43557 ret_ref = (uintptr_t)ret_var.inner;
43558 if (ret_var.is_owned) {
43559         ret_ref |= 1;
43560 }
43561         return ret_ref;
43562 }
43563 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
43564         LDKInvoiceSignature arg_conv;
43565         arg_conv.inner = (void*)(arg & (~1));
43566         arg_conv.is_owned = false;
43567         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43568         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
43569         return ret_conv;
43570 }
43571
43572 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
43573         LDKInvoiceSignature orig_conv;
43574         orig_conv.inner = (void*)(orig & (~1));
43575         orig_conv.is_owned = false;
43576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43577         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
43578         uint32_t ret_ref = 0;
43579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43582         ret_ref = (uintptr_t)ret_var.inner;
43583         if (ret_var.is_owned) {
43584                 ret_ref |= 1;
43585         }
43586         return ret_ref;
43587 }
43588
43589 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
43590         LDKInvoiceSignature a_conv;
43591         a_conv.inner = (void*)(a & (~1));
43592         a_conv.is_owned = false;
43593         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43594         LDKInvoiceSignature b_conv;
43595         b_conv.inner = (void*)(b & (~1));
43596         b_conv.is_owned = false;
43597         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43598         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
43599         return ret_conv;
43600 }
43601
43602 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
43603         LDKPrivateRoute this_obj_conv;
43604         this_obj_conv.inner = (void*)(this_obj & (~1));
43605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43607         PrivateRoute_free(this_obj_conv);
43608 }
43609
43610 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
43611         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
43612 uint32_t ret_ref = 0;
43613 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43614 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43615 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43616 ret_ref = (uintptr_t)ret_var.inner;
43617 if (ret_var.is_owned) {
43618         ret_ref |= 1;
43619 }
43620         return ret_ref;
43621 }
43622 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
43623         LDKPrivateRoute arg_conv;
43624         arg_conv.inner = (void*)(arg & (~1));
43625         arg_conv.is_owned = false;
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43627         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
43628         return ret_conv;
43629 }
43630
43631 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
43632         LDKPrivateRoute orig_conv;
43633         orig_conv.inner = (void*)(orig & (~1));
43634         orig_conv.is_owned = false;
43635         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43636         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
43637         uint32_t ret_ref = 0;
43638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43641         ret_ref = (uintptr_t)ret_var.inner;
43642         if (ret_var.is_owned) {
43643                 ret_ref |= 1;
43644         }
43645         return ret_ref;
43646 }
43647
43648 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
43649         LDKPrivateRoute o_conv;
43650         o_conv.inner = (void*)(o & (~1));
43651         o_conv.is_owned = false;
43652         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43653         int64_t ret_conv = PrivateRoute_hash(&o_conv);
43654         return ret_conv;
43655 }
43656
43657 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
43658         LDKPrivateRoute a_conv;
43659         a_conv.inner = (void*)(a & (~1));
43660         a_conv.is_owned = false;
43661         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43662         LDKPrivateRoute b_conv;
43663         b_conv.inner = (void*)(b & (~1));
43664         b_conv.is_owned = false;
43665         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43666         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
43667         return ret_conv;
43668 }
43669
43670 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
43671         LDKSignedRawInvoice this_arg_conv;
43672         this_arg_conv.inner = (void*)(this_arg & (~1));
43673         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43675         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
43676         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
43677         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
43678         return ((uint32_t)ret_conv);
43679 }
43680
43681 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
43682         LDKSignedRawInvoice this_arg_conv;
43683         this_arg_conv.inner = (void*)(this_arg & (~1));
43684         this_arg_conv.is_owned = false;
43685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43686         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
43687         uint32_t ret_ref = 0;
43688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43691         ret_ref = (uintptr_t)ret_var.inner;
43692         if (ret_var.is_owned) {
43693                 ret_ref |= 1;
43694         }
43695         return ret_ref;
43696 }
43697
43698 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
43699         LDKSignedRawInvoice this_arg_conv;
43700         this_arg_conv.inner = (void*)(this_arg & (~1));
43701         this_arg_conv.is_owned = false;
43702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43703         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43704         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
43705         return ret_arr;
43706 }
43707
43708 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
43709         LDKSignedRawInvoice this_arg_conv;
43710         this_arg_conv.inner = (void*)(this_arg & (~1));
43711         this_arg_conv.is_owned = false;
43712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43713         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
43714         uint32_t ret_ref = 0;
43715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43718         ret_ref = (uintptr_t)ret_var.inner;
43719         if (ret_var.is_owned) {
43720                 ret_ref |= 1;
43721         }
43722         return ret_ref;
43723 }
43724
43725 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
43726         LDKSignedRawInvoice this_arg_conv;
43727         this_arg_conv.inner = (void*)(this_arg & (~1));
43728         this_arg_conv.is_owned = false;
43729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43730         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
43731         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
43732         return (uint32_t)ret_conv;
43733 }
43734
43735 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
43736         LDKSignedRawInvoice this_arg_conv;
43737         this_arg_conv.inner = (void*)(this_arg & (~1));
43738         this_arg_conv.is_owned = false;
43739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43740         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
43741         return ret_conv;
43742 }
43743
43744 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
43745         LDKRawInvoice this_arg_conv;
43746         this_arg_conv.inner = (void*)(this_arg & (~1));
43747         this_arg_conv.is_owned = false;
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43749         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43750         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
43751         return ret_arr;
43752 }
43753
43754 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
43755         LDKRawInvoice this_arg_conv;
43756         this_arg_conv.inner = (void*)(this_arg & (~1));
43757         this_arg_conv.is_owned = false;
43758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43759         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
43760         uint32_t ret_ref = 0;
43761         if ((uintptr_t)ret_var.inner > 4096) {
43762                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43763                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43765                 ret_ref = (uintptr_t)ret_var.inner;
43766                 if (ret_var.is_owned) {
43767                         ret_ref |= 1;
43768                 }
43769         }
43770         return ret_ref;
43771 }
43772
43773 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
43774         LDKRawInvoice this_arg_conv;
43775         this_arg_conv.inner = (void*)(this_arg & (~1));
43776         this_arg_conv.is_owned = false;
43777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43778         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
43779         uint32_t ret_ref = 0;
43780         if ((uintptr_t)ret_var.inner > 4096) {
43781                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43782                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43784                 ret_ref = (uintptr_t)ret_var.inner;
43785                 if (ret_var.is_owned) {
43786                         ret_ref |= 1;
43787                 }
43788         }
43789         return ret_ref;
43790 }
43791
43792 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
43793         LDKRawInvoice this_arg_conv;
43794         this_arg_conv.inner = (void*)(this_arg & (~1));
43795         this_arg_conv.is_owned = false;
43796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43797         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
43798         uint32_t ret_ref = 0;
43799         if ((uintptr_t)ret_var.inner > 4096) {
43800                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43801                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43803                 ret_ref = (uintptr_t)ret_var.inner;
43804                 if (ret_var.is_owned) {
43805                         ret_ref |= 1;
43806                 }
43807         }
43808         return ret_ref;
43809 }
43810
43811 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
43812         LDKRawInvoice this_arg_conv;
43813         this_arg_conv.inner = (void*)(this_arg & (~1));
43814         this_arg_conv.is_owned = false;
43815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43816         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
43817         uint32_t ret_ref = 0;
43818         if ((uintptr_t)ret_var.inner > 4096) {
43819                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43820                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43822                 ret_ref = (uintptr_t)ret_var.inner;
43823                 if (ret_var.is_owned) {
43824                         ret_ref |= 1;
43825                 }
43826         }
43827         return ret_ref;
43828 }
43829
43830 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
43831         LDKRawInvoice this_arg_conv;
43832         this_arg_conv.inner = (void*)(this_arg & (~1));
43833         this_arg_conv.is_owned = false;
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43835         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
43836         uint32_t ret_ref = 0;
43837         if ((uintptr_t)ret_var.inner > 4096) {
43838                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43839                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43841                 ret_ref = (uintptr_t)ret_var.inner;
43842                 if (ret_var.is_owned) {
43843                         ret_ref |= 1;
43844                 }
43845         }
43846         return ret_ref;
43847 }
43848
43849 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
43850         LDKRawInvoice this_arg_conv;
43851         this_arg_conv.inner = (void*)(this_arg & (~1));
43852         this_arg_conv.is_owned = false;
43853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43854         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
43855         uint32_t ret_ref = 0;
43856         if ((uintptr_t)ret_var.inner > 4096) {
43857                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43858                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43860                 ret_ref = (uintptr_t)ret_var.inner;
43861                 if (ret_var.is_owned) {
43862                         ret_ref |= 1;
43863                 }
43864         }
43865         return ret_ref;
43866 }
43867
43868 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
43869         LDKRawInvoice this_arg_conv;
43870         this_arg_conv.inner = (void*)(this_arg & (~1));
43871         this_arg_conv.is_owned = false;
43872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43873         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43874         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
43875         return ret_arr;
43876 }
43877
43878 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
43879         LDKRawInvoice this_arg_conv;
43880         this_arg_conv.inner = (void*)(this_arg & (~1));
43881         this_arg_conv.is_owned = false;
43882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43883         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
43884         uint32_t ret_ref = 0;
43885         if ((uintptr_t)ret_var.inner > 4096) {
43886                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43887                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43889                 ret_ref = (uintptr_t)ret_var.inner;
43890                 if (ret_var.is_owned) {
43891                         ret_ref |= 1;
43892                 }
43893         }
43894         return ret_ref;
43895 }
43896
43897 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
43898         LDKRawInvoice this_arg_conv;
43899         this_arg_conv.inner = (void*)(this_arg & (~1));
43900         this_arg_conv.is_owned = false;
43901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43902         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
43903         uint32_tArray ret_arr = NULL;
43904         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
43905         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
43906         for (size_t o = 0; o < ret_var.datalen; o++) {
43907                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
43908                 uint32_t ret_conv_14_ref = 0;
43909                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43910                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43911                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
43912                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
43913                 if (ret_conv_14_var.is_owned) {
43914                         ret_conv_14_ref |= 1;
43915                 }
43916                 ret_arr_ptr[o] = ret_conv_14_ref;
43917         }
43918         
43919         FREE(ret_var.data);
43920         return ret_arr;
43921 }
43922
43923 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
43924         LDKRawInvoice this_arg_conv;
43925         this_arg_conv.inner = (void*)(this_arg & (~1));
43926         this_arg_conv.is_owned = false;
43927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43928         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43929         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
43930         uint32_t ret_ref = (uintptr_t)ret_copy;
43931         return ret_ref;
43932 }
43933
43934 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
43935         LDKRawInvoice this_arg_conv;
43936         this_arg_conv.inner = (void*)(this_arg & (~1));
43937         this_arg_conv.is_owned = false;
43938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43939         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
43940         return ret_conv;
43941 }
43942
43943 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
43944         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43945         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
43946         return (uint32_t)ret_conv;
43947 }
43948
43949 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
43950         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43951         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
43952         return (uint32_t)ret_conv;
43953 }
43954
43955 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
43956         LDKPositiveTimestamp this_arg_conv;
43957         this_arg_conv.inner = (void*)(this_arg & (~1));
43958         this_arg_conv.is_owned = false;
43959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43960         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
43961         return ret_conv;
43962 }
43963
43964 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
43965         LDKPositiveTimestamp this_arg_conv;
43966         this_arg_conv.inner = (void*)(this_arg & (~1));
43967         this_arg_conv.is_owned = false;
43968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43969         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
43970         return ret_conv;
43971 }
43972
43973 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
43974         LDKInvoice this_arg_conv;
43975         this_arg_conv.inner = (void*)(this_arg & (~1));
43976         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43978         this_arg_conv = Invoice_clone(&this_arg_conv);
43979         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
43980         uint32_t ret_ref = 0;
43981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43984         ret_ref = (uintptr_t)ret_var.inner;
43985         if (ret_var.is_owned) {
43986                 ret_ref |= 1;
43987         }
43988         return ret_ref;
43989 }
43990
43991 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
43992         LDKInvoice this_arg_conv;
43993         this_arg_conv.inner = (void*)(this_arg & (~1));
43994         this_arg_conv.is_owned = false;
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43996         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
43997         *ret_conv = Invoice_check_signature(&this_arg_conv);
43998         return (uint32_t)ret_conv;
43999 }
44000
44001 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
44002         LDKSignedRawInvoice signed_invoice_conv;
44003         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
44004         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
44005         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
44006         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
44007         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
44008         *ret_conv = Invoice_from_signed(signed_invoice_conv);
44009         return (uint32_t)ret_conv;
44010 }
44011
44012 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
44013         LDKInvoice this_arg_conv;
44014         this_arg_conv.inner = (void*)(this_arg & (~1));
44015         this_arg_conv.is_owned = false;
44016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44017         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
44018         return ret_conv;
44019 }
44020
44021 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
44022         LDKInvoice this_arg_conv;
44023         this_arg_conv.inner = (void*)(this_arg & (~1));
44024         this_arg_conv.is_owned = false;
44025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44026         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44027         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
44028         return ret_arr;
44029 }
44030
44031 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
44032         LDKInvoice this_arg_conv;
44033         this_arg_conv.inner = (void*)(this_arg & (~1));
44034         this_arg_conv.is_owned = false;
44035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44036         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44037         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
44038         return ret_arr;
44039 }
44040
44041 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
44042         LDKInvoice this_arg_conv;
44043         this_arg_conv.inner = (void*)(this_arg & (~1));
44044         this_arg_conv.is_owned = false;
44045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44046         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44047         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
44048         return ret_arr;
44049 }
44050
44051 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
44052         LDKInvoice this_arg_conv;
44053         this_arg_conv.inner = (void*)(this_arg & (~1));
44054         this_arg_conv.is_owned = false;
44055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44056         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
44057         uint32_t ret_ref = 0;
44058         if ((uintptr_t)ret_var.inner > 4096) {
44059                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44060                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44062                 ret_ref = (uintptr_t)ret_var.inner;
44063                 if (ret_var.is_owned) {
44064                         ret_ref |= 1;
44065                 }
44066         }
44067         return ret_ref;
44068 }
44069
44070 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
44071         LDKInvoice this_arg_conv;
44072         this_arg_conv.inner = (void*)(this_arg & (~1));
44073         this_arg_conv.is_owned = false;
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44075         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44076         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
44077         return ret_arr;
44078 }
44079
44080 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
44081         LDKInvoice this_arg_conv;
44082         this_arg_conv.inner = (void*)(this_arg & (~1));
44083         this_arg_conv.is_owned = false;
44084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44085         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
44086         return ret_conv;
44087 }
44088
44089 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
44090         LDKInvoice this_arg_conv;
44091         this_arg_conv.inner = (void*)(this_arg & (~1));
44092         this_arg_conv.is_owned = false;
44093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44094         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
44095         return ret_conv;
44096 }
44097
44098 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
44099         LDKInvoice this_arg_conv;
44100         this_arg_conv.inner = (void*)(this_arg & (~1));
44101         this_arg_conv.is_owned = false;
44102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44103         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
44104         return ret_conv;
44105 }
44106
44107 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
44108         LDKInvoice this_arg_conv;
44109         this_arg_conv.inner = (void*)(this_arg & (~1));
44110         this_arg_conv.is_owned = false;
44111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44112         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
44113         uint32_tArray ret_arr = NULL;
44114         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44115         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44116         for (size_t o = 0; o < ret_var.datalen; o++) {
44117                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44118                 uint32_t ret_conv_14_ref = 0;
44119                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44120                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44121                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44122                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44123                 if (ret_conv_14_var.is_owned) {
44124                         ret_conv_14_ref |= 1;
44125                 }
44126                 ret_arr_ptr[o] = ret_conv_14_ref;
44127         }
44128         
44129         FREE(ret_var.data);
44130         return ret_arr;
44131 }
44132
44133 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
44134         LDKInvoice this_arg_conv;
44135         this_arg_conv.inner = (void*)(this_arg & (~1));
44136         this_arg_conv.is_owned = false;
44137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44138         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
44139         uint32_tArray ret_arr = NULL;
44140         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44141         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44142         for (size_t l = 0; l < ret_var.datalen; l++) {
44143                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44144                 uint32_t ret_conv_11_ref = 0;
44145                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44146                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44147                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44148                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44149                 if (ret_conv_11_var.is_owned) {
44150                         ret_conv_11_ref |= 1;
44151                 }
44152                 ret_arr_ptr[l] = ret_conv_11_ref;
44153         }
44154         
44155         FREE(ret_var.data);
44156         return ret_arr;
44157 }
44158
44159 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
44160         LDKInvoice this_arg_conv;
44161         this_arg_conv.inner = (void*)(this_arg & (~1));
44162         this_arg_conv.is_owned = false;
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44164         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
44165         return ret_conv;
44166 }
44167
44168 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
44169         LDKInvoice this_arg_conv;
44170         this_arg_conv.inner = (void*)(this_arg & (~1));
44171         this_arg_conv.is_owned = false;
44172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44173         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44174         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
44175         uint32_t ret_ref = (uintptr_t)ret_copy;
44176         return ret_ref;
44177 }
44178
44179 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
44180         LDKStr description_conv = str_ref_to_owned_c(description);
44181         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
44182         *ret_conv = Description_new(description_conv);
44183         return (uint32_t)ret_conv;
44184 }
44185
44186 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
44187         LDKDescription this_arg_conv;
44188         this_arg_conv.inner = (void*)(this_arg & (~1));
44189         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44191         this_arg_conv = Description_clone(&this_arg_conv);
44192         LDKStr ret_str = Description_into_inner(this_arg_conv);
44193         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44194         Str_free(ret_str);
44195         return ret_conv;
44196 }
44197
44198 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
44199         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
44200         uint32_t ret_ref = 0;
44201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44204         ret_ref = (uintptr_t)ret_var.inner;
44205         if (ret_var.is_owned) {
44206                 ret_ref |= 1;
44207         }
44208         return ret_ref;
44209 }
44210
44211 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
44212         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
44213         uint32_t ret_ref = 0;
44214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44217         ret_ref = (uintptr_t)ret_var.inner;
44218         if (ret_var.is_owned) {
44219                 ret_ref |= 1;
44220         }
44221         return ret_ref;
44222 }
44223
44224 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
44225         LDKExpiryTime this_arg_conv;
44226         this_arg_conv.inner = (void*)(this_arg & (~1));
44227         this_arg_conv.is_owned = false;
44228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44229         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
44230         return ret_conv;
44231 }
44232
44233 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
44234         LDKExpiryTime this_arg_conv;
44235         this_arg_conv.inner = (void*)(this_arg & (~1));
44236         this_arg_conv.is_owned = false;
44237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44238         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
44239         return ret_conv;
44240 }
44241
44242 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
44243         LDKRouteHint hops_conv;
44244         hops_conv.inner = (void*)(hops & (~1));
44245         hops_conv.is_owned = (hops & 1) || (hops == 0);
44246         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
44247         hops_conv = RouteHint_clone(&hops_conv);
44248         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
44249         *ret_conv = PrivateRoute_new(hops_conv);
44250         return (uint32_t)ret_conv;
44251 }
44252
44253 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
44254         LDKPrivateRoute this_arg_conv;
44255         this_arg_conv.inner = (void*)(this_arg & (~1));
44256         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44258         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
44259         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
44260         uint32_t ret_ref = 0;
44261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44264         ret_ref = (uintptr_t)ret_var.inner;
44265         if (ret_var.is_owned) {
44266                 ret_ref |= 1;
44267         }
44268         return ret_ref;
44269 }
44270
44271 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
44272         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
44273         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
44274         return ret_conv;
44275 }
44276
44277 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
44278         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
44279         return ret_conv;
44280 }
44281
44282 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
44283         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
44284         return ret_conv;
44285 }
44286
44287 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
44288         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
44289         return ret_conv;
44290 }
44291
44292 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
44293         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
44294         return ret_conv;
44295 }
44296
44297 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
44298         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
44299         return ret_conv;
44300 }
44301
44302 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
44303         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
44304         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
44305         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
44306         return ret_conv;
44307 }
44308
44309 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
44310         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
44311         LDKStr ret_str = CreationError_to_str(o_conv);
44312         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44313         Str_free(ret_str);
44314         return ret_conv;
44315 }
44316
44317 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
44318         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
44319         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
44320         return ret_conv;
44321 }
44322
44323 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
44324         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
44325         return ret_conv;
44326 }
44327
44328 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
44329         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
44330         return ret_conv;
44331 }
44332
44333 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
44334         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
44335         return ret_conv;
44336 }
44337
44338 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
44339         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
44340         return ret_conv;
44341 }
44342
44343 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
44344         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
44345         return ret_conv;
44346 }
44347
44348 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
44349         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
44350         return ret_conv;
44351 }
44352
44353 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
44354         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
44355         return ret_conv;
44356 }
44357
44358 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
44359         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
44360         return ret_conv;
44361 }
44362
44363 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
44364         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
44365         return ret_conv;
44366 }
44367
44368 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
44369         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
44370         return ret_conv;
44371 }
44372
44373 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
44374         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
44375         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
44376         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
44377         return ret_conv;
44378 }
44379
44380 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
44381         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
44382         LDKStr ret_str = SemanticError_to_str(o_conv);
44383         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44384         Str_free(ret_str);
44385         return ret_conv;
44386 }
44387
44388 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
44389         if ((this_ptr & 1) != 0) return;
44390         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44391         CHECK_ACCESS(this_ptr_ptr);
44392         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
44393         FREE((void*)this_ptr);
44394         SignOrCreationError_free(this_ptr_conv);
44395 }
44396
44397 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
44398         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44399         *ret_copy = SignOrCreationError_clone(arg);
44400 uint32_t ret_ref = (uintptr_t)ret_copy;
44401         return ret_ref;
44402 }
44403 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
44404         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
44405         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
44406         return ret_conv;
44407 }
44408
44409 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
44410         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
44411         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44412         *ret_copy = SignOrCreationError_clone(orig_conv);
44413         uint32_t ret_ref = (uintptr_t)ret_copy;
44414         return ret_ref;
44415 }
44416
44417 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
44418         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44419         *ret_copy = SignOrCreationError_sign_error();
44420         uint32_t ret_ref = (uintptr_t)ret_copy;
44421         return ret_ref;
44422 }
44423
44424 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
44425         LDKCreationError a_conv = LDKCreationError_from_js(a);
44426         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44427         *ret_copy = SignOrCreationError_creation_error(a_conv);
44428         uint32_t ret_ref = (uintptr_t)ret_copy;
44429         return ret_ref;
44430 }
44431
44432 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
44433         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
44434         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
44435         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
44436         return ret_conv;
44437 }
44438
44439 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
44440         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
44441         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
44442         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44443         Str_free(ret_str);
44444         return ret_conv;
44445 }
44446
44447 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
44448         LDKInvoicePayer this_obj_conv;
44449         this_obj_conv.inner = (void*)(this_obj & (~1));
44450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44452         InvoicePayer_free(this_obj_conv);
44453 }
44454
44455 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
44456         if ((this_ptr & 1) != 0) return;
44457         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44458         CHECK_ACCESS(this_ptr_ptr);
44459         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
44460         FREE((void*)this_ptr);
44461         Payer_free(this_ptr_conv);
44462 }
44463
44464 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
44465         if ((this_ptr & 1) != 0) return;
44466         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44467         CHECK_ACCESS(this_ptr_ptr);
44468         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
44469         FREE((void*)this_ptr);
44470         Router_free(this_ptr_conv);
44471 }
44472
44473 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
44474         if ((this_ptr & 1) != 0) return;
44475         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44476         CHECK_ACCESS(this_ptr_ptr);
44477         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
44478         FREE((void*)this_ptr);
44479         Retry_free(this_ptr_conv);
44480 }
44481
44482 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
44483         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44484         *ret_copy = Retry_clone(arg);
44485 uint32_t ret_ref = (uintptr_t)ret_copy;
44486         return ret_ref;
44487 }
44488 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
44489         LDKRetry* arg_conv = (LDKRetry*)arg;
44490         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
44491         return ret_conv;
44492 }
44493
44494 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
44495         LDKRetry* orig_conv = (LDKRetry*)orig;
44496         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44497         *ret_copy = Retry_clone(orig_conv);
44498         uint32_t ret_ref = (uintptr_t)ret_copy;
44499         return ret_ref;
44500 }
44501
44502 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
44503         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44504         *ret_copy = Retry_attempts(a);
44505         uint32_t ret_ref = (uintptr_t)ret_copy;
44506         return ret_ref;
44507 }
44508
44509 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
44510         LDKRetry* a_conv = (LDKRetry*)a;
44511         LDKRetry* b_conv = (LDKRetry*)b;
44512         jboolean ret_conv = Retry_eq(a_conv, b_conv);
44513         return ret_conv;
44514 }
44515
44516 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
44517         LDKRetry* o_conv = (LDKRetry*)o;
44518         int64_t ret_conv = Retry_hash(o_conv);
44519         return ret_conv;
44520 }
44521
44522 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
44523         if ((this_ptr & 1) != 0) return;
44524         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44525         CHECK_ACCESS(this_ptr_ptr);
44526         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
44527         FREE((void*)this_ptr);
44528         PaymentError_free(this_ptr_conv);
44529 }
44530
44531 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
44532         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44533         *ret_copy = PaymentError_clone(arg);
44534 uint32_t ret_ref = (uintptr_t)ret_copy;
44535         return ret_ref;
44536 }
44537 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
44538         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
44539         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
44540         return ret_conv;
44541 }
44542
44543 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
44544         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
44545         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44546         *ret_copy = PaymentError_clone(orig_conv);
44547         uint32_t ret_ref = (uintptr_t)ret_copy;
44548         return ret_ref;
44549 }
44550
44551 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
44552         LDKStr a_conv = str_ref_to_owned_c(a);
44553         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44554         *ret_copy = PaymentError_invoice(a_conv);
44555         uint32_t ret_ref = (uintptr_t)ret_copy;
44556         return ret_ref;
44557 }
44558
44559 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
44560         LDKLightningError a_conv;
44561         a_conv.inner = (void*)(a & (~1));
44562         a_conv.is_owned = (a & 1) || (a == 0);
44563         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44564         a_conv = LightningError_clone(&a_conv);
44565         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44566         *ret_copy = PaymentError_routing(a_conv);
44567         uint32_t ret_ref = (uintptr_t)ret_copy;
44568         return ret_ref;
44569 }
44570
44571 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
44572         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
44573         CHECK_ACCESS(a_ptr);
44574         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
44575         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
44576         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44577         *ret_copy = PaymentError_sending(a_conv);
44578         uint32_t ret_ref = (uintptr_t)ret_copy;
44579         return ret_ref;
44580 }
44581
44582 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) {
44583         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
44584         CHECK_ACCESS(payer_ptr);
44585         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
44586         if (payer_conv.free == LDKPayer_JCalls_free) {
44587                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44588                 LDKPayer_JCalls_cloned(&payer_conv);
44589         }
44590         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
44591         CHECK_ACCESS(router_ptr);
44592         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
44593         if (router_conv.free == LDKRouter_JCalls_free) {
44594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44595                 LDKRouter_JCalls_cloned(&router_conv);
44596         }
44597         LDKMultiThreadedLockableScore scorer_conv;
44598         scorer_conv.inner = (void*)(scorer & (~1));
44599         scorer_conv.is_owned = false;
44600         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
44601         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44602         CHECK_ACCESS(logger_ptr);
44603         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44604         if (logger_conv.free == LDKLogger_JCalls_free) {
44605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44606                 LDKLogger_JCalls_cloned(&logger_conv);
44607         }
44608         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
44609         CHECK_ACCESS(event_handler_ptr);
44610         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
44611         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
44612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44613                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
44614         }
44615         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
44616         CHECK_ACCESS(retry_ptr);
44617         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
44618         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
44619         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
44620         uint32_t ret_ref = 0;
44621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44624         ret_ref = (uintptr_t)ret_var.inner;
44625         if (ret_var.is_owned) {
44626                 ret_ref |= 1;
44627         }
44628         return ret_ref;
44629 }
44630
44631 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
44632         LDKInvoicePayer this_arg_conv;
44633         this_arg_conv.inner = (void*)(this_arg & (~1));
44634         this_arg_conv.is_owned = false;
44635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44636         LDKInvoice invoice_conv;
44637         invoice_conv.inner = (void*)(invoice & (~1));
44638         invoice_conv.is_owned = false;
44639         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44640         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44641         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
44642         return (uint32_t)ret_conv;
44643 }
44644
44645 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) {
44646         LDKInvoicePayer this_arg_conv;
44647         this_arg_conv.inner = (void*)(this_arg & (~1));
44648         this_arg_conv.is_owned = false;
44649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44650         LDKInvoice invoice_conv;
44651         invoice_conv.inner = (void*)(invoice & (~1));
44652         invoice_conv.is_owned = false;
44653         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44654         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44655         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
44656         return (uint32_t)ret_conv;
44657 }
44658
44659 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) {
44660         LDKInvoicePayer this_arg_conv;
44661         this_arg_conv.inner = (void*)(this_arg & (~1));
44662         this_arg_conv.is_owned = false;
44663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44664         LDKPublicKey pubkey_ref;
44665         CHECK(pubkey->arr_len == 33);
44666         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
44667         LDKThirtyTwoBytes payment_preimage_ref;
44668         CHECK(payment_preimage->arr_len == 32);
44669         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
44670         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44671         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
44672         return (uint32_t)ret_conv;
44673 }
44674
44675 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
44676         LDKInvoicePayer this_arg_conv;
44677         this_arg_conv.inner = (void*)(this_arg & (~1));
44678         this_arg_conv.is_owned = false;
44679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44680         unsigned char payment_hash_arr[32];
44681         CHECK(payment_hash->arr_len == 32);
44682         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
44683         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
44684         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
44685 }
44686
44687 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
44688         LDKInvoicePayer this_arg_conv;
44689         this_arg_conv.inner = (void*)(this_arg & (~1));
44690         this_arg_conv.is_owned = false;
44691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44692         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
44693         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
44694         return (uint32_t)ret_ret;
44695 }
44696
44697 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) {
44698         LDKChannelManager channelmanager_conv;
44699         channelmanager_conv.inner = (void*)(channelmanager & (~1));
44700         channelmanager_conv.is_owned = false;
44701         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
44702         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
44703         CHECK_ACCESS(keys_manager_ptr);
44704         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
44705         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
44706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44707                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
44708         }
44709         LDKCurrency network_conv = LDKCurrency_from_js(network);
44710         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
44711         CHECK_ACCESS(amt_msat_ptr);
44712         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
44713         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
44714         LDKSha256 description_hash_conv;
44715         description_hash_conv.inner = (void*)(description_hash & (~1));
44716         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
44717         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
44718         description_hash_conv = Sha256_clone(&description_hash_conv);
44719         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
44720         *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);
44721         return (uint32_t)ret_conv;
44722 }
44723
44724 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) {
44725         LDKChannelManager channelmanager_conv;
44726         channelmanager_conv.inner = (void*)(channelmanager & (~1));
44727         channelmanager_conv.is_owned = false;
44728         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
44729         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
44730         CHECK_ACCESS(keys_manager_ptr);
44731         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
44732         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
44733                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44734                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
44735         }
44736         LDKCurrency network_conv = LDKCurrency_from_js(network);
44737         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
44738         CHECK_ACCESS(amt_msat_ptr);
44739         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
44740         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
44741         LDKStr description_conv = str_ref_to_owned_c(description);
44742         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
44743         *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);
44744         return (uint32_t)ret_conv;
44745 }
44746
44747 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
44748         LDKDefaultRouter this_obj_conv;
44749         this_obj_conv.inner = (void*)(this_obj & (~1));
44750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44752         DefaultRouter_free(this_obj_conv);
44753 }
44754
44755 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
44756         LDKNetworkGraph network_graph_conv;
44757         network_graph_conv.inner = (void*)(network_graph & (~1));
44758         network_graph_conv.is_owned = false;
44759         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44760         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44761         CHECK_ACCESS(logger_ptr);
44762         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44763         if (logger_conv.free == LDKLogger_JCalls_free) {
44764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44765                 LDKLogger_JCalls_cloned(&logger_conv);
44766         }
44767         LDKThirtyTwoBytes random_seed_bytes_ref;
44768         CHECK(random_seed_bytes->arr_len == 32);
44769         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
44770         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
44771         uint32_t ret_ref = 0;
44772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44775         ret_ref = (uintptr_t)ret_var.inner;
44776         if (ret_var.is_owned) {
44777                 ret_ref |= 1;
44778         }
44779         return ret_ref;
44780 }
44781
44782 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
44783         LDKDefaultRouter this_arg_conv;
44784         this_arg_conv.inner = (void*)(this_arg & (~1));
44785         this_arg_conv.is_owned = false;
44786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44787         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
44788         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
44789         return (uint32_t)ret_ret;
44790 }
44791
44792 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
44793         LDKChannelManager this_arg_conv;
44794         this_arg_conv.inner = (void*)(this_arg & (~1));
44795         this_arg_conv.is_owned = false;
44796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44797         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
44798         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
44799         return (uint32_t)ret_ret;
44800 }
44801
44802 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
44803         LDKStr s_conv = str_ref_to_owned_c(s);
44804         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
44805         *ret_conv = SiPrefix_from_str(s_conv);
44806         return (uint32_t)ret_conv;
44807 }
44808
44809 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
44810         LDKStr s_conv = str_ref_to_owned_c(s);
44811         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
44812         *ret_conv = Invoice_from_str(s_conv);
44813         return (uint32_t)ret_conv;
44814 }
44815
44816 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
44817         LDKStr s_conv = str_ref_to_owned_c(s);
44818         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
44819         *ret_conv = SignedRawInvoice_from_str(s_conv);
44820         return (uint32_t)ret_conv;
44821 }
44822
44823 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
44824         LDKParseError* o_conv = (LDKParseError*)o;
44825         LDKStr ret_str = ParseError_to_str(o_conv);
44826         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44827         Str_free(ret_str);
44828         return ret_conv;
44829 }
44830
44831 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
44832         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
44833         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
44834         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44835         Str_free(ret_str);
44836         return ret_conv;
44837 }
44838
44839 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
44840         LDKInvoice o_conv;
44841         o_conv.inner = (void*)(o & (~1));
44842         o_conv.is_owned = false;
44843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44844         LDKStr ret_str = Invoice_to_str(&o_conv);
44845         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44846         Str_free(ret_str);
44847         return ret_conv;
44848 }
44849
44850 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
44851         LDKSignedRawInvoice o_conv;
44852         o_conv.inner = (void*)(o & (~1));
44853         o_conv.is_owned = false;
44854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44855         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
44856         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44857         Str_free(ret_str);
44858         return ret_conv;
44859 }
44860
44861 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
44862         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44863         LDKStr ret_str = Currency_to_str(o_conv);
44864         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44865         Str_free(ret_str);
44866         return ret_conv;
44867 }
44868
44869 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
44870         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
44871         LDKStr ret_str = SiPrefix_to_str(o_conv);
44872         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44873         Str_free(ret_str);
44874         return ret_conv;
44875 }
44876